Class: Keisanjaku::ProcedureCapture

Inherits:
Object
  • Object
show all
Defined in:
lib/keisanjaku/procedure.rb

Constant Summary collapse

POSITION_TOLERANCE =
0.002

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plan) ⇒ ProcedureCapture

Returns a new instance of ProcedureCapture.



22
23
24
25
26
# File 'lib/keisanjaku/procedure.rb', line 22

def initialize(plan)
  @steps = plan&.steps || []
  @index = 0
  @events = []
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



20
21
22
# File 'lib/keisanjaku/procedure.rb', line 20

def events
  @events
end

Instance Method Details

#record_satisfied!(state, trigger: nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/keisanjaku/procedure.rb', line 28

def record_satisfied!(state, trigger: nil)
  loop do
    step = @steps[@index]
    break unless step_satisfied?(step, state, trigger)

    @events << ProcedureEvent.from_step(step)
    @index += 1
    trigger = nil
  end
  events
end