Class: DiscreteEvent::Simulation
- Inherits:
-
EventQueue
- Object
- EventQueue
- DiscreteEvent::Simulation
- Defined in:
- lib/discrete_event/simulation.rb
Overview
A simulation, including an EventQueue, the current time, and various helpers.
See the README for an example.
Instance Attribute Summary
Attributes inherited from EventQueue
Instance Method Summary collapse
-
#run { ... } ⇒ nil
Run (or continue, if there are existing events) the simulation until
:stop
is thrown, or there are no more events. -
#start ⇒ Object
abstract
Called by
run
when beginning a new simulation; you will probably want to override this.
Methods inherited from EventQueue
#after, #at, #at_each, #each, #every, #initialize, #next_event_time, #recur_after, #reset, #run_next
Constructor Details
This class inherits a constructor from DiscreteEvent::EventQueue
Instance Method Details
#run { ... } ⇒ nil
Run (or continue, if there are existing events) the simulation until :stop
is thrown, or there are no more events.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/discrete_event/simulation.rb', line 25 def run &block start if @events.empty? catch :stop do if block_given? yield while run_next else nil while run_next end end end |
#start ⇒ Object
This method is abstract.
Called by run
when beginning a new simulation; you will probably want to override this.
15 16 |
# File 'lib/discrete_event/simulation.rb', line 15 def start end |