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
def initialize transition_table
  @tt = transition_table
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
def simulate string
  input = StringScanner.new string
  state = [0]
  while sym = input.scan(/[\/\.\?]|[^\/\.\?]+/)
    state = tt.move(state, sym)
  end

  acceptance_states = state.find_all { |s|
    tt.accepting? s
  }

  return if acceptance_states.empty?

  memos = acceptance_states.map { |x| tt.memo x }.flatten.compact

  MatchData.new memos
end
Also aliased as: =~, match

[Validate]

Generated with the Darkfish Rdoc Generator 2.