Class: Retrograph::Easy::PeriodicManager
- Inherits:
-
Object
- Object
- Retrograph::Easy::PeriodicManager
- Defined in:
- lib/retrograph/easy/periodic.rb
Instance Method Summary collapse
- #already?(label) ⇒ Boolean
- #frame_for?(label) ⇒ Boolean
-
#initialize ⇒ PeriodicManager
constructor
A new instance of PeriodicManager.
- #phase_of(label) ⇒ Object
- #start(label, interval, phases) ⇒ Object
- #stop(label) ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize ⇒ PeriodicManager
Returns a new instance of PeriodicManager.
49 50 51 |
# File 'lib/retrograph/easy/periodic.rb', line 49 def initialize @named_periodics = {} end |
Instance Method Details
#already?(label) ⇒ Boolean
76 77 78 79 |
# File 'lib/retrograph/easy/periodic.rb', line 76 def already?(label) label = label.to_sym @named_periodics.has_key? label end |
#frame_for?(label) ⇒ Boolean
66 67 68 69 70 71 72 73 74 |
# File 'lib/retrograph/easy/periodic.rb', line 66 def frame_for?(label) label = label.to_sym begin periodic = @named_periodics.fetch label rescue IndexError return false end periodic.firing? end |
#phase_of(label) ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/retrograph/easy/periodic.rb', line 81 def phase_of(label) label = label.to_sym begin periodic = @named_periodics.fetch label rescue IndexError return 0 end periodic.phase end |
#start(label, interval, phases) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/retrograph/easy/periodic.rb', line 53 def start(label, interval, phases) label = label.to_sym periodic = Periodic.new(interval, phases) @named_periodics[label] = periodic nil end |
#stop(label) ⇒ Object
60 61 62 63 64 |
# File 'lib/retrograph/easy/periodic.rb', line 60 def stop(label) label = label.to_sym @named_periodics.delete label nil end |
#tick ⇒ Object
91 92 93 94 95 |
# File 'lib/retrograph/easy/periodic.rb', line 91 def tick @named_periodics.each_value do |periodic| periodic.tick end end |