Class: ActionDispatch::Journey::GTG::Simulator
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/journey/gtg/simulator.rb |
Constant Summary
-
INITIAL_STATE =
# File 'actionpack/lib/action_dispatch/journey/gtg/simulator.rb', line 19[ [0, nil] ].freeze
Class Method Summary
- .new(transition_table) ⇒ Simulator constructor
Instance Attribute Summary
- #tt readonly
Instance Method Summary
Constructor Details
.new(transition_table) ⇒ Simulator
# File 'actionpack/lib/action_dispatch/journey/gtg/simulator.rb', line 23
def initialize(transition_table) @tt = transition_table end
Instance Attribute Details
#tt (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/gtg/simulator.rb', line 21
attr_reader :tt
Instance Method Details
#memos(string)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/gtg/simulator.rb', line 27
def memos(string) input = StringScanner.new(string) state = INITIAL_STATE start_index = 0 while sym = input.scan(%r([/.?]|[^/.?]+)) end_index = start_index + sym.length state = tt.move(state, string, start_index, end_index) start_index = end_index end acceptance_states = state.each_with_object([]) do |s_d, memos| s, idx = s_d memos.concat(tt.memo(s)) if idx.nil? && tt.accepting?(s) end acceptance_states.empty? ? yield : acceptance_states end