Class: Tomograph::Path

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Path

Returns a new instance of Path.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/tomograph/path.rb', line 5

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 Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/tomograph/path.rb', line 3

def path
  @path
end

Instance Method Details

#==(other) ⇒ Object



34
35
36
# File 'lib/tomograph/path.rb', line 34

def ==(other)
  other.instance_of?(self.class) && (other.path == path)
end

#match(find_path) ⇒ Object



17
18
19
# File 'lib/tomograph/path.rb', line 17

def match(find_path)
  regexp =~ find_path
end

#regexpObject



21
22
23
24
25
26
27
28
# File 'lib/tomograph/path.rb', line 21

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



30
31
32
# File 'lib/tomograph/path.rb', line 30

def to_s
  @path
end