Class: Fader

Inherits:
Object show all
Defined in:
lib/fader.rb

Overview

An initial value, a

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#expObject

getter



12
13
14
# File 'lib/fader.rb', line 12

def exp
  @exp
end

#finalObject

The final value.



6
7
8
# File 'lib/fader.rb', line 6

def final
  @final
end

#startObject

The initial value.



4
5
6
# File 'lib/fader.rb', line 4

def start
  @start
end

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_nilObject



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