Class: Dugway::PathInterpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/dugway/path_interpreter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PathInterpreter

Returns a new instance of PathInterpreter.



5
6
7
# File 'lib/dugway/path_interpreter.rb', line 5

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/dugway/path_interpreter.rb', line 3

def path
  @path
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dugway/path_interpreter.rb', line 9

def call
  return path unless path.is_a?(String)
  case path
  when category_artist_or_product_path
    %r{^/#{$1}/(?<#{$2}>#{permalink_regex})#{format_regex}$}
  when product_or_cart_path
    %r{^/#{$1}#{format_regex}$}
  when custom_page_path
    %r{^/(?<#{$1}>#{permalink_regex})$}
  else
    %r{^#{path}$}
  end
end