Class: SimulatorTimeline::States

Inherits:
Object
  • Object
show all
Defined in:
app/models/simulator_timeline/states.rb

Instance Method Summary collapse

Constructor Details

#initialize(timeline) {|_self| ... } ⇒ States

Returns a new instance of States.

Yields:

  • (_self)

Yield Parameters:



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, options = {})
  @timeline.states << [time, state, options]
end