Class: ActionDispatch::Journey::Visitors::String

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/journey/visitors.rb

Overview

:nodoc:

Constant Summary collapse

INSTANCE =
new

Instance Method Summary collapse

Instance Method Details

#accept(node, seed) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 171

def accept(node, seed)
  case node.type
  when :DOT
    seed << node.left
  when :LITERAL
    seed << node.left
  when :SYMBOL
    seed << node.left
  when :SLASH
    seed << node.left
  when :CAT
    accept(node.right, accept(node.left, seed))
  when :STAR
    accept(node.left, seed)
  when :OR
    last_child = node.children.last
    node.children.each do |c|
      accept(c, seed)
      seed << "|" unless last_child == c
    end
    seed
  when :GROUP
    accept(node.left, seed << "(") << ")"
  else
    raise "Unknown node type: #{node.type}"
  end
end