Class: Tomograph::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/tomograph/path.rb

Instance Method Summary collapse

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

#regexpObject



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_sObject



28
29
30
# File 'lib/tomograph/path.rb', line 28

def to_s
  @path
end