Class: CheekyPi::Animation::Cycle
- Defined in:
- lib/cheeky-pi/animation/cycle.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
- #cycle_percent ⇒ Object
-
#initialize(duration, light, options = {}) ⇒ Cycle
constructor
A new instance of Cycle.
Methods inherited from Base
#animate, #complete, #halt, #handle_complete, #percent, #promise, #safe_percent, #sine, #start, #tick, #triangle
Constructor Details
#initialize(duration, light, options = {}) ⇒ Cycle
Returns a new instance of Cycle.
7 8 9 10 11 12 13 |
# File 'lib/cheeky-pi/animation/cycle.rb', line 7 def initialize(duration, light, ={}) super @to = [:to] @from = [:from] @period = [:period] end |
Instance Method Details
#cycle_percent ⇒ Object
15 16 17 |
# File 'lib/cheeky-pi/animation/cycle.rb', line 15 def cycle_percent ((Time.now.to_f - @start_time) % @period) / @period end |