method
move
v7.1.3.2 -
Show latest stable
-
0 notes -
Class: TransitionTable
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
move(t, full_string, start_index, end_index)
public
Hide source
# File actionpack/lib/action_dispatch/journey/gtg/transition_table.rb, line 48 def move(t, full_string, start_index, end_index) return [] if t.empty? next_states = [] tok = full_string.slice(start_index, end_index - start_index) token_matches_default_component = DEFAULT_EXP_ANCHORED.match?(tok) t.each { |s, previous_start| if previous_start.nil? # In the simple case of a "default" param regex do this fast-path # and add all next states. if token_matches_default_component && states = @stdparam_states[s] states.each { |re, v| next_states << [v, nil].freeze if !v.nil? } end # When we have a literal string, we can just pull the next state if states = @string_states[s] next_states << [states[tok], nil].freeze unless states[tok].nil? end end # For regexes that aren't the "default" style, they may potentially # not be terminated by the first "token" [./?], so we need to continue # to attempt to match this regexp as well as any successful paths that # continue out of it. both paths could be valid. if states = @regexp_states[s] slice_start = if previous_start.nil? start_index else previous_start end slice_length = end_index - slice_start curr_slice = full_string.slice(slice_start, slice_length) states.each { |re, v| # if we match, we can try moving past this next_states << [v, nil].freeze if !v.nil? && re.match?(curr_slice) } # and regardless, we must continue accepting tokens and retrying this regexp. # we need to remember where we started as well so we can take bigger slices. next_states << [s, slice_start].freeze end } next_states end