class Dugway::PathInterpreter
Attributes
path[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/dugway/path_interpreter.rb, line 5 def initialize(path) @path = path end
Public Instance Methods
call()
click to toggle source
# 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
Private Instance Methods
category_artist_or_product_path()
click to toggle source
# File lib/dugway/path_interpreter.rb, line 33 def category_artist_or_product_path %r{^/(\w+)/:(#{permalink_regex})\(\.js\)} end
custom_page_path()
click to toggle source
# File lib/dugway/path_interpreter.rb, line 41 def custom_page_path %r{^/:(#{permalink_regex})} end
format_regex()
click to toggle source
# File lib/dugway/path_interpreter.rb, line 29 def format_regex %r{(\.(?<format>js))?} end
permalink_regex()
click to toggle source
# File lib/dugway/path_interpreter.rb, line 25 def permalink_regex %r{[a-z0-9\-_]+} end
product_or_cart_path()
click to toggle source
# File lib/dugway/path_interpreter.rb, line 37 def product_or_cart_path %r{^/(\w+)\(\.js\)$} end