Parent

Journey::GTG::Simulator

Attributes

tt[R]

Public Class Methods

new(transition_table) click to toggle source
    # File lib/journey/gtg/simulator.rb, line 16
16:       def initialize transition_table
17:         @tt = transition_table
18:       end

Public Instance Methods

=~(string) click to toggle source
Alias for: simulate
match(string) click to toggle source
Alias for: simulate
simulate(string) click to toggle source
    # File lib/journey/gtg/simulator.rb, line 20
20:       def simulate string
21:         input = StringScanner.new string
22:         state = [0]
23:         while sym = input.scan(/[\/\.\?]|[^\/\.\?]+/)
24:           state = tt.move(state, sym)
25:         end
26: 
27:         acceptance_states = state.find_all { |s|
28:           tt.accepting? s
29:         }
30: 
31:         return if acceptance_states.empty?
32: 
33:         memos = acceptance_states.map { |x| tt.memo x }.flatten.compact
34: 
35:         MatchData.new memos
36:       end
Also aliased as: =~, match

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.