class ActionDispatch::Journey::Path::Pattern::AnchoredRegexp
:nodoc:
def accept(node)
def accept(node) %r{\A#{visit node}\Z} end
def initialize(separator, matchers)
def initialize(separator, matchers) @separator = separator @matchers = matchers @separator_re = "([^#{separator}]+)" super() end
def visit_CAT(node)
def visit_CAT(node) "#{visit(node.left)}#{visit(node.right)}" end
def visit_GROUP(node)
def visit_GROUP(node) "(?:#{visit node.left})?" end
def visit_LITERAL(node)
def visit_LITERAL(node) Regexp.escape(node.left) end
def visit_OR(node)
def visit_OR(node) children = node.children.map { |n| visit n } "(?:#{children.join(?|)})" end
def visit_SLASH(node)
def visit_SLASH(node) node.left end
def visit_STAR(node)
def visit_STAR(node) re = @matchers[node.left.to_sym] re ? "(#{re})" : "(.+)" end
def visit_SYMBOL(node)
def visit_SYMBOL(node) node = node.to_sym return @separator_re unless @matchers.key?(node) re = @matchers[node] "(#{Regexp.union(re)})" end