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
Constructor Details
#initialize(start = nil, final = nil, exp = 0) ⇒ Fader
Returns a new instance of Fader.
13 14 15 16 17 |
# File 'lib/fader.rb', line 13 def initialize(start=nil,final=nil,exp=0) @start = start @final = final @exp = exp end |
Instance Attribute Details
Instance Method Details
#%(percent) ⇒ Object
set #final to a percentage of start
19 20 21 |
# File 'lib/fader.rb', line 19 def %(percent) self.final = start.to_f*(percent/100.0) end |
#*(mul = 0.5) ⇒ Object
operate on both start and final
23 24 25 26 |
# File 'lib/fader.rb', line 23 def *(mul=0.5) self.start *= mul self.final *= mul end |
#exp_no_nil ⇒ Object
31 32 33 |
# File 'lib/fader.rb', line 31 def exp_no_nil @exp.nil? ? 0 : @exp end |
#is_eql(other) ⇒ Object
34 35 36 |
# File 'lib/fader.rb', line 34 def is_eql(other) vars_eql?(other) end |