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.



11
12
13
# File 'lib/assert/file_line.rb', line 11

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.



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

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

Class Method Details

.parse(file_line_path) ⇒ Object



5
6
7
# File 'lib/assert/file_line.rb', line 5

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



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

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



15
16
17
# File 'lib/assert/file_line.rb', line 15

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