Module: NT54::Parser::Machinery::ClassMethods

Defined in:
lib/nt54/parser/machinery.rb

Instance Method Summary collapse

Instance Method Details

#transition(from, to) ⇒ Object



38
39
40
# File 'lib/nt54/parser/machinery.rb', line 38

def transition(from, to)
  transitions[triggers.last][from] = to
end

#transitionsObject



42
43
44
# File 'lib/nt54/parser/machinery.rb', line 42

def transitions
  @transitions ||= {}
end

#trigger(name, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/nt54/parser/machinery.rb', line 27

def trigger(name, &block)
  triggers << name
  transitions[name] = {}
  class_eval(<<-END, __FILE__, __LINE__ + 1)
    def #{name}
      NT54.log.debug "triggering #{name}" if NT54.log
      machine.trigger :#{name}
    end
  END
end

#triggersObject



46
47
48
# File 'lib/nt54/parser/machinery.rb', line 46

def triggers
  @triggers ||= []
end