Method: Journey::Path::Pattern#initialize

Defined in:
lib/journey/path/pattern.rb

#initialize(strexp) ⇒ Pattern

Returns a new instance of Pattern.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/journey/path/pattern.rb', line 6

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 "wtf bro: #{strexp}"
  end

  @names          = nil
  @optional_names = nil
  @required_names = nil
  @re             = nil
  @offsets        = nil
end