Class: ActionDispatch::Journey::Visitors::FunctionalVisitor

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

Overview

:nodoc:

Direct Known Subclasses

Dot, Each, String

Constant Summary collapse

DISPATCH_CACHE =
{}

Instance Method Summary collapse

Instance Method Details

#accept(node, seed) ⇒ Object



98
99
100
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 98

def accept(node, seed)
  visit(node, seed)
end

#binary(node, seed) ⇒ Object



106
107
108
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 106

def binary(node, seed)
  visit(node.right, visit(node.left, seed))
end

#nary(node, seed) ⇒ Object



111
112
113
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 111

def nary(node, seed)
  node.children.inject(seed) { |s, c| visit(c, s) }
end

#terminal(node, seed) ⇒ Object



122
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 122

def terminal(node, seed);   seed; end

#unary(node, seed) ⇒ Object



116
117
118
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 116

def unary(node, seed)
  visit(node.left, seed)
end

#visit(node, seed) ⇒ Object



102
103
104
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 102

def visit(node, seed)
  send(DISPATCH_CACHE[node.type], node, seed)
end

#visit_CAT(n, seed) ⇒ Object



109
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 109

def visit_CAT(n, seed); binary(n, seed); end

#visit_DOT(n, seed) ⇒ Object



126
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 126

def visit_DOT(n, seed);     terminal(n, seed); end

#visit_GROUP(n, seed) ⇒ Object



119
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 119

def visit_GROUP(n, seed); unary(n, seed); end

#visit_LITERAL(n, seed) ⇒ Object



123
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 123

def visit_LITERAL(n, seed); terminal(n, seed); end

#visit_OR(n, seed) ⇒ Object



114
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 114

def visit_OR(n, seed); nary(n, seed); end

#visit_SLASH(n, seed) ⇒ Object



125
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 125

def visit_SLASH(n, seed);   terminal(n, seed); end

#visit_STAR(n, seed) ⇒ Object



120
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 120

def visit_STAR(n, seed); unary(n, seed); end

#visit_SYMBOL(n, seed) ⇒ Object



124
# File 'actionpack/lib/action_dispatch/journey/visitors.rb', line 124

def visit_SYMBOL(n, seed);  terminal(n, seed); end