Class: SimulatorTimeline::States
- Inherits:
-
Object
- Object
- SimulatorTimeline::States
- Defined in:
- app/models/simulator_timeline/states.rb
Instance Method Summary collapse
- #add_transition(state, time, options = {}) ⇒ Object
-
#initialize(timeline) {|_self| ... } ⇒ States
constructor
A new instance of States.
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(timeline) {|_self| ... } ⇒ States
Returns a new instance of States.
3 4 5 6 7 |
# File 'app/models/simulator_timeline/states.rb', line 3 def initialize(timeline) @timeline = timeline yield(self) finish_initialize end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/models/simulator_timeline/states.rb', line 13 def method_missing(method_name, *args, &block) if SimulatorMatch::STATUS_SEQUENCE[method_name] add_transition(method_name, args.first) else super(method_name, *args, &block) end end |
Instance Method Details
#add_transition(state, time, options = {}) ⇒ Object
9 10 11 |
# File 'app/models/simulator_timeline/states.rb', line 9 def add_transition(state, time, = {}) @timeline.states << [time, state, ] end |