Module: Aygabtu::PointOfCall

Extended by:
PointOfCall
Included in:
PointOfCall
Defined in:
lib/aygabtu/point_of_call.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.gem_rootObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/aygabtu/point_of_call.rb', line 17

def self.gem_root
  @gem_root ||= begin
    path = Pathname(__FILE__)
    while new_path = path.parent and new_path.to_s.include?('lib/aygabtu')
      path = new_path
    end

    path.to_s
  end
end

Instance Method Details

#file_and_line_at_point_of_callObject



12
13
14
15
# File 'lib/aygabtu/point_of_call.rb', line 12

def file_and_line_at_point_of_call
  filename, line_and_context = point_of_call.split(':', 2)
  [filename, line_and_context.to_i] # make use of the fact to_i tolerates being passed a string only _beginning_ with a number
end

#point_of_callObject



8
9
10
# File 'lib/aygabtu/point_of_call.rb', line 8

def point_of_call
  caller.drop_while { |point| point.start_with?(PointOfCall.gem_root) }.first
end