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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcdef3b21d2be6f436c54df25801ddfbf7d8997a
4
- data.tar.gz: 97822e8388112ffcecf9dc616f0a2459132c7712
3
+ metadata.gz: e2f5d387991ffe41db7cc423ecf4a24cb44a157e
4
+ data.tar.gz: a88db90d00b14cce95d9d9e647d2eea99c0f22d2
5
5
  SHA512:
6
- metadata.gz: c2895a20f52a76fc9ee2f2d9c8a770dca0ddeb9586958d9ad4617990f7073ae0f219e977e78292c34f4544de0f9268132ddd942af56b0bc67103cf29f2740bb0
7
- data.tar.gz: 1cce63a88b3b75a6a4428433e5e5c0490f292b8817f20733eb74f8c147e8eb9a0356e9ad62d2e96cacaae12d7aea77f0516fb748da5d90f45d5c1c3771d92c2b
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[3].to_sym]
55
+ @tolerance = Resistor::ColorCode::TOLERANCE[@code[-1].to_sym]
56
56
  end
57
57
 
58
58
  # Calculates a series combined resistance value.
@@ -1,3 +1,3 @@
1
1
  module Resistor
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resistor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - seinosuke