Class: Tomograph::Path
- Inherits:
-
Object
- Object
- Tomograph::Path
- Defined in:
- lib/tomograph/path.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ Path
constructor
A new instance of Path.
- #match(find_path) ⇒ Object
- #regexp ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ Path
Returns a new instance of Path.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/tomograph/path.rb', line 3 def initialize(path) unless path && !path.empty? @path = '' return end @path = path @path = delete_till_the_end('{&') @path = delete_till_the_end('{?') @path = cut_off_query_params @path = remove_the_slash_at_the_end end |
Instance Method Details
#match(find_path) ⇒ Object
15 16 17 |
# File 'lib/tomograph/path.rb', line 15 def match(find_path) regexp =~ find_path end |
#regexp ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/tomograph/path.rb', line 19 def regexp return @regexp if @regexp str = Regexp.escape(to_s) str = str.gsub(/\\{\w+\\}/, '[^&=\/]+') str = "\\A#{str}\\z" @regexp = Regexp.new(str) end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/tomograph/path.rb', line 28 def to_s @path end |