Class: Assert::FileLine

Inherits:
Object
  • Object
show all
Defined in:
lib/assert/file_line.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil, line = nil) ⇒ FileLine

Returns a new instance of FileLine.



9
10
11
# File 'lib/assert/file_line.rb', line 9

def initialize(file = nil, line = nil)
  @file, @line = file.to_s, line.to_s
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/assert/file_line.rb', line 7

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



7
8
9
# File 'lib/assert/file_line.rb', line 7

def line
  @line
end

Class Method Details

.parse(file_line_path) ⇒ Object



3
4
5
# File 'lib/assert/file_line.rb', line 3

def self.parse(file_line_path)
  self.new(*(file_line_path.to_s.match(/(^[^\:]*)\:*(\d*).*$/) || [])[1..2])
end

Instance Method Details

#==(other_file_line) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/assert/file_line.rb', line 17

def ==(other_file_line)
  if other_file_line.kind_of?(FileLine)
    self.file == other_file_line.file &&
    self.line == other_file_line.line
  else
    super
  end
end

#to_sObject



13
14
15
# File 'lib/assert/file_line.rb', line 13

def to_s
  "#{self.file}:#{self.line}"
end