Class: Motion::Launchpad::Schedule
- Inherits:
-
Object
- Object
- Motion::Launchpad::Schedule
- Defined in:
- lib/motion/launchpad/schedule.rb
Instance Attribute Summary collapse
-
#preferences_key ⇒ Object
Returns the value of attribute preferences_key.
Instance Method Summary collapse
- #configure {|_self| ... } ⇒ Object
- #events ⇒ Object
-
#initialize(options = {}, &block) ⇒ Schedule
constructor
A new instance of Schedule.
- #on(count, &block) ⇒ Object
- #run! ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Schedule
Returns a new instance of Schedule.
6 7 8 9 10 11 |
# File 'lib/motion/launchpad/schedule.rb', line 6 def initialize(={}, &block) self.preferences_key = .fetch(:preferences_key, :launch_count) @events = [] handle_launch end |
Instance Attribute Details
#preferences_key ⇒ Object
Returns the value of attribute preferences_key.
4 5 6 |
# File 'lib/motion/launchpad/schedule.rb', line 4 def preferences_key @preferences_key end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
13 14 15 |
# File 'lib/motion/launchpad/schedule.rb', line 13 def configure yield(self) if block_given? end |
#events ⇒ Object
25 26 27 |
# File 'lib/motion/launchpad/schedule.rb', line 25 def events @events.select { |e| e.applicable?(launch_count) } end |
#on(count, &block) ⇒ Object
17 18 19 |
# File 'lib/motion/launchpad/schedule.rb', line 17 def on(count, &block) @events << Event.new(count, block) end |
#run! ⇒ Object
21 22 23 |
# File 'lib/motion/launchpad/schedule.rb', line 21 def run! events.each { |e| e.call } end |