class ActionDispatch::Journey::Path::Pattern

:nodoc:
:nodoc:
:nodoc:

def ast

def ast
  @spec.grep(Nodes::Symbol).each do |node|
    re = @requirements[node.to_sym]
    node.regexp = re if re
  end
  @spec.grep(Nodes::Star).each do |node|
    node = node.left
    node.regexp = @requirements[node.to_sym] || /(.+)/
  end
  @spec
end

def initialize(strexp)

def initialize(strexp)
  parser = Journey::Parser.new
  @anchored = true
  case strexp
  when String
    @spec         = parser.parse(strexp)
    @requirements = {}
    @separators   = "/.?"
  when Router::Strexp
    @spec         = parser.parse(strexp.path)
    @requirements = strexp.requirements
    @separators   = strexp.separators.join
    @anchored     = strexp.anchor
  else
    raise ArgumentError, "Bad expression: #{strexp}"
  end
  @names          = nil
  @optional_names = nil
  @required_names = nil
  @re             = nil
  @offsets        = nil
end

def match(other)

def match(other)
  return unless match = to_regexp.match(other)
  MatchData.new(names, offsets, match)
end

def names

def names
  @names ||= spec.grep(Nodes::Symbol).map { |n| n.name }
end

def offsets

def offsets
  return @offsets if @offsets
  viz = RegexpOffsets.new(@requirements)
  @offsets = viz.accept(spec)
end

def optional_names

def optional_names
  @optional_names ||= spec.grep(Nodes::Group).map { |group|
    group.grep(Nodes::Symbol)
  }.flatten.map { |n| n.name }.uniq
end

def regexp_visitor

def regexp_visitor
  @anchored ? AnchoredRegexp : UnanchoredRegexp
end

def required_names

def required_names
  @required_names ||= names - optional_names
end

def source

def source
  to_regexp.source
end

def to_regexp

def to_regexp
  @re ||= regexp_visitor.new(@separators, @requirements).accept spec
end