Class: TraceViewer::LineDetail

Inherits:
Object
  • Object
show all
Defined in:
lib/trace_viewer/line_detail.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



3
4
5
# File 'lib/trace_viewer/line_detail.rb', line 3

def filename
  @filename
end

#function_nodeObject

Returns the value of attribute function_node.



3
4
5
# File 'lib/trace_viewer/line_detail.rb', line 3

def function_node
  @function_node
end

#line_numberObject

Returns the value of attribute line_number.



3
4
5
# File 'lib/trace_viewer/line_detail.rb', line 3

def line_number
  @line_number
end

#sourceObject

Returns the value of attribute source.



3
4
5
# File 'lib/trace_viewer/line_detail.rb', line 3

def source
  @source
end

Instance Method Details

#formatted_sourceObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/trace_viewer/line_detail.rb', line 9

def formatted_source
  @formatted_source ||= begin
    if (source)
      source = self.source.clone
      source[0] =~ /^(\s+)/
      leading_characters = $1 || ''
      source.map {|line|
        line ? line.sub(leading_characters, '') : nil
      }
    else
      []
    end
  end
end

#line_countObject



5
6
7
# File 'lib/trace_viewer/line_detail.rb', line 5

def line_count
  formatted_source.size
end