Class: Fader
Overview
An initial value, a
Instance Attribute Summary collapse
-
#exp ⇒ Object
getter.
-
#final ⇒ Object
The final value.
-
#start ⇒ Object
The initial value.
Instance Method Summary collapse
-
#%(percent) ⇒ Object
set #final to a percentage of start.
-
#*(mul = 0.5) ⇒ Object
operate on both start and final.
- #exp_no_nil ⇒ Object
-
#initialize(start = nil, final = nil, exp = 0) ⇒ Fader
constructor
A new instance of Fader.
- #is_eql(other) ⇒ Object
-
#rand_exp ⇒ Object
randomize the exp with good values.
Constructor Details
Instance Attribute Details
Instance Method Details
#%(percent) ⇒ Object
set #final to a percentage of start
23 24 25 |
# File 'lib/fader.rb', line 23 def %(percent) self.final = start.to_f*(percent/100.0) end |
#*(mul = 0.5) ⇒ Object
operate on both start and final
27 28 29 30 |
# File 'lib/fader.rb', line 27 def *(mul=0.5) self.start *= mul self.final *= mul end |
#exp_no_nil ⇒ Object
35 36 37 |
# File 'lib/fader.rb', line 35 def exp_no_nil @exp.nil? ? 0 : @exp end |
#is_eql(other) ⇒ Object
38 39 40 |
# File 'lib/fader.rb', line 38 def is_eql(other) vars_eql?(other) end |
#rand_exp ⇒ Object
randomize the exp with good values.
19 20 21 |
# File 'lib/fader.rb', line 19 def rand_exp self.exp = 0.20 * rand(100) end |