class MetricAdapter::Location

Attributes

line[R]
path[R]

Public Class Methods

new(combined_path, line = 0) click to toggle source
# File lib/location.rb, line 5
def initialize(combined_path, line = 0)
  @path, @line = parse_path(combined_path || '')
  @line ||= line
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/location.rb, line 14
def <=>(other)
  [path,line] <=> [other.path, other.line]
end
to_s() click to toggle source
# File lib/location.rb, line 10
def to_s
  "#{path}:#{line}"
end

Private Instance Methods

has_line_number?(path) click to toggle source
# File lib/location.rb, line 31
def has_line_number?(path)
  !!(path =~ /\:\d+\s*$/)
end
parse_path(path) click to toggle source
# File lib/location.rb, line 20
def parse_path(path)
  path = path.strip
  
  if has_line_number?(path)
    *path_chunks, line = path.split(':')
    [path_chunks.join(':'), line.to_i]
  else
    [path,nil]
  end
end