Module: DiscreteEvent::Events
- Defined in:
- lib/discrete_event/events.rb
Overview
Mix-in for simulations with multiple objects that have to share the same clock. See the README for an example.
The implementing class must have an instance method event_queue
that returns the EventQueue to use; this method may be private.
Instance Method Summary collapse
- #after(delay) { ... } ⇒ Event
- #at(time) { ... } ⇒ Event
- #at_each(elements, time = nil) {|element| ... } ⇒ nil
- #cancel(event) ⇒ nil
- #every(interval, start = 0, &action) ⇒ nil
- #now ⇒ Number
- #recur_after(interval) ⇒ nil
Instance Method Details
#after(delay) { ... } ⇒ Event
34 35 36 |
# File 'lib/discrete_event/events.rb', line 34 def after(delay, &action) event_queue.after(delay, &action) end |
#at(time) { ... } ⇒ Event
21 22 23 |
# File 'lib/discrete_event/events.rb', line 21 def at(time, &action) event_queue.at(time, &action) end |
#at_each(elements, time = nil) {|element| ... } ⇒ nil
68 69 70 |
# File 'lib/discrete_event/events.rb', line 68 def at_each(elements, time = nil, &action) event_queue.at_each(elements, time, &action) end |
#cancel(event) ⇒ nil
43 44 45 |
# File 'lib/discrete_event/events.rb', line 43 def cancel(event) event_queue.cancel(event) end |
#every(interval, start = 0, &action) ⇒ nil
91 92 93 |
# File 'lib/discrete_event/events.rb', line 91 def every(interval, start = 0, &action) event_queue.every(interval, start, &action) end |
#now ⇒ Number
100 101 102 |
# File 'lib/discrete_event/events.rb', line 100 def now event_queue.now end |
#recur_after(interval) ⇒ nil
79 80 81 |
# File 'lib/discrete_event/events.rb', line 79 def recur_after(interval) event_queue.recur_after(interval) end |