resistor 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resistor/basic_resistor.rb +1 -1
- data/lib/resistor/version.rb +1 -1
- data/spec/basic_resistor_spec.rb +19 -0
- 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: e2f5d387991ffe41db7cc423ecf4a24cb44a157e
|
4
|
+
data.tar.gz: a88db90d00b14cce95d9d9e647d2eea99c0f22d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e724399fff5b814f3a18902cc6682e84526b6a198c91beb3e02e87ab334f0d5cb1b4c75ff3653ab69f1d8534bb5132946c743583a68f1a1485b80dfcc7bc12
|
7
|
+
data.tar.gz: 639c8c53cf4981861f8b9376225024407ed9755b11e5468b6ad692454bf9ab1de1c2af8a37ffe08bfc02cdd6eedcec0e3419b0ce0eb714a2b2e563e1120817c7
|
@@ -52,7 +52,7 @@ module Resistor
|
|
52
52
|
def code=(code)
|
53
53
|
@code = code.map(&:to_sym)
|
54
54
|
@ohm = Resistor::ColorCode.decode(@code)
|
55
|
-
@tolerance = Resistor::ColorCode::TOLERANCE[@code[
|
55
|
+
@tolerance = Resistor::ColorCode::TOLERANCE[@code[-1].to_sym]
|
56
56
|
end
|
57
57
|
|
58
58
|
# Calculates a series combined resistance value.
|
data/lib/resistor/version.rb
CHANGED
data/spec/basic_resistor_spec.rb
CHANGED
@@ -119,6 +119,15 @@ describe Resistor::BasicResistor do
|
|
119
119
|
it { expect(resistor.code).to eq [:yellow, :purple, :gold, :gold] }
|
120
120
|
end
|
121
121
|
|
122
|
+
context '5本帯の抵抗値を変更する場合' do
|
123
|
+
Resistor::Options.set_band_number 5
|
124
|
+
resistor = Resistor.new(100)
|
125
|
+
resistor.ohm = 475
|
126
|
+
it { expect(resistor.ohm).to eq 475.0 }
|
127
|
+
it { expect(resistor.code).to eq [:yellow, :purple, :green, :black, :brown] }
|
128
|
+
Resistor::Options.set_band_number 4
|
129
|
+
end
|
130
|
+
|
122
131
|
context 'カラーコードを変更する場合' do
|
123
132
|
resistor = Resistor.new(100)
|
124
133
|
resistor.code = ['green', 'brown', 'silver', 'brown']
|
@@ -126,6 +135,16 @@ describe Resistor::BasicResistor do
|
|
126
135
|
it { expect(resistor.code).to eq [:green, :brown, :silver, :brown] }
|
127
136
|
it { expect(resistor.tolerance).to eq 1.0 }
|
128
137
|
end
|
138
|
+
|
139
|
+
context '5本帯のカラーコードを変更する場合' do
|
140
|
+
Resistor::Options.set_band_number 5
|
141
|
+
resistor = Resistor.new(100)
|
142
|
+
resistor.code = ['brown', 'green', 'yellow', 'silver', 'red']
|
143
|
+
it { expect(resistor.ohm).to eq 1.54 }
|
144
|
+
it { expect(resistor.code).to eq [:brown, :green, :yellow, :silver, :red] }
|
145
|
+
it { expect(resistor.tolerance).to eq 2.0 }
|
146
|
+
Resistor::Options.set_band_number 4
|
147
|
+
end
|
129
148
|
end
|
130
149
|
|
131
150
|
describe '#e12?' do
|