Class: WaveInt
- Inherits:
-
Object
- Object
- WaveInt
- Defined in:
- lib/wave_int.rb,
lib/wave_int/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
-
#initialize(limit1, limit2 = 0) ⇒ WaveInt
constructor
Set WaveInt Range.
-
#value(number = @v) ⇒ Object
Get WaveInt Value.(default: return last value).
Constructor Details
#initialize(limit1, limit2 = 0) ⇒ WaveInt
Set WaveInt Range.
5 6 7 8 |
# File 'lib/wave_int.rb', line 5 def initialize(limit1, limit2=0) @min, @max = [limit1.to_i, limit2.to_i].sort @v = @min end |
Instance Method Details
#value(number = @v) ⇒ Object
Get WaveInt Value.(default: return last value)
11 12 13 14 15 |
# File 'lib/wave_int.rb', line 11 def value(number = @v) n = (number.to_i - offset) % (cycle) @v = offset + (n < wave_max ? n : cycle - n) @v end |