Class: MethodLog::MethodDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/method_log/method_definition.rb

Instance Method Summary collapse

Constructor Details

#initialize(source_file: nil, lines: nil) ⇒ MethodDefinition

Returns a new instance of MethodDefinition.



3
4
5
6
# File 'lib/method_log/method_definition.rb', line 3

def initialize(source_file: nil, lines: nil)
  @source_file = source_file
  @lines = lines
end

Instance Method Details

#==(other) ⇒ Object



8
9
10
# File 'lib/method_log/method_definition.rb', line 8

def ==(other)
  (source_file == other.source_file) && (lines == other.lines)
end

#hashObject



12
13
14
# File 'lib/method_log/method_definition.rb', line 12

def hash
  [source_file, lines].hash
end

#to_sObject



16
17
18
19
20
21
# File 'lib/method_log/method_definition.rb', line 16

def to_s
  [
    "#{source_file.path}:#{lines}",
    source_file.snippet(lines)
  ].join($/)
end