electric 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/electric/resistor.rb +11 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02742beca6cabb448b85703e30cdc829008f4129
|
4
|
+
data.tar.gz: 7a471903b9aa74579dbb9db0f2ce458d2e8167e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 743679e89445520340da808332e78f63f222fb7aae0b5d5b8e4067ca0bf76eefcc5a323b656259c6f04c639aba3b0041ccc2791de5f90af79a77cfeddd60af1c
|
7
|
+
data.tar.gz: 7e63781573ee7525f5328555d87b19cb7a25eb445c7b81e4a48733224e23de8482df947b8b01f502ec2115c816166be48a846e409acf91868bbae5a8089dee51
|
data/lib/electric/resistor.rb
CHANGED
@@ -11,20 +11,24 @@ module Electric
|
|
11
11
|
|
12
12
|
def human_readable
|
13
13
|
if value >= 1000000
|
14
|
-
"#{round_for(value / 1000000.0)}M ohms#{color_to_tolerance(@fourth)}"
|
14
|
+
"#{round_for(value / 1000000.0)}M ohms, +/- #{color_to_tolerance(@fourth)}"
|
15
15
|
elsif value >= 1000
|
16
|
-
"#{round_for(value / 1000.0)}K ohms#{color_to_tolerance(@fourth)}"
|
16
|
+
"#{round_for(value / 1000.0)}K ohms, +/- #{color_to_tolerance(@fourth)}"
|
17
17
|
else
|
18
|
-
"#{value} ohms#{color_to_tolerance(@fourth)}"
|
18
|
+
"#{value} ohms, +/- #{color_to_tolerance(@fourth)}"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
private
|
23
|
-
|
24
22
|
def value
|
25
23
|
"#{color_to_number(first)}#{color_to_number(second)}".to_i * color_to_multiplier(third)
|
26
24
|
end
|
27
25
|
|
26
|
+
def tolerance
|
27
|
+
color_to_tolerance(@fourth)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
28
32
|
def color_to_number(color)
|
29
33
|
colors = {
|
30
34
|
"black" => 0,
|
@@ -61,8 +65,8 @@ module Electric
|
|
61
65
|
|
62
66
|
def color_to_tolerance(color)
|
63
67
|
colors = {
|
64
|
-
"gold" => "
|
65
|
-
"silver" => "
|
68
|
+
"gold" => "5%",
|
69
|
+
"silver" => "10%"
|
66
70
|
}
|
67
71
|
colors[color.downcase]
|
68
72
|
end
|