Class: Betterp::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/betterp/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, base_path) ⇒ Source

Returns a new instance of Source.



5
6
7
8
9
# File 'lib/betterp/source.rb', line 5

def initialize(source, base_path)
  @source = source
  @base_path = base_path
  @path, @line_no, @method_info = source.split(':')
end

Instance Method Details

#line_noObject



17
18
19
# File 'lib/betterp/source.rb', line 17

def line_no
  @line_no.to_i
end

#method_nameObject



21
22
23
# File 'lib/betterp/source.rb', line 21

def method_name
  @method_info.partition('`').last.chomp("'")
end

#pathObject



11
12
13
14
15
# File 'lib/betterp/source.rb', line 11

def path
  Pathname.new(@path).relative_path_from(Pathname.new(@base_path)).to_s
rescue ArgumentError
  @path
end