Class: Calyx::Format::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/calyx/format.rb

Instance Method Summary collapse

Constructor Details

#initialize(match_symbol, filename, contents) ⇒ Trace

Returns a new instance of Trace.



8
9
10
11
12
# File 'lib/calyx/format.rb', line 8

def initialize(match_symbol, filename, contents)
  @match_symbol = match_symbol
  @filename = Pathname.new(filename)
  @contents = contents
end

Instance Method Details

#absolute_pathObject



18
19
20
# File 'lib/calyx/format.rb', line 18

def absolute_path
  @filename.expand_path
end

#linenoObject



22
23
24
25
26
27
28
# File 'lib/calyx/format.rb', line 22

def lineno
  line_number = 0
  @contents.each_line do |line|
    line_number += 1
    return line_number if line =~ @match_symbol
  end
end

#pathObject



14
15
16
# File 'lib/calyx/format.rb', line 14

def path
  @filename.basename
end