Class: CheekyPi::Animation::Cycle

Inherits:
Base
  • Object
show all
Defined in:
lib/cheeky-pi/animation/cycle.rb

Direct Known Subclasses

Throb

Constant Summary

Constants inherited from Base

Base::TICKRATE

Instance Method Summary collapse

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, options={})
  super

  @to = options[:to]
  @from = options[:from]
  @period = options[:period]
end

Instance Method Details

#cycle_percentObject



15
16
17
# File 'lib/cheeky-pi/animation/cycle.rb', line 15

def cycle_percent
  ((Time.now.to_f - @start_time) % @period) / @period
end