class CC::Analyzer::Formatters::HTMLFormatter::Location
Constants
- CONTEXT_LINES
- MAX_LINES
Attributes
location[R]
source_buffer[R]
Public Class Methods
new(source_buffer, location)
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 161 def initialize(source_buffer, location) @source_buffer = source_buffer @location = location end
Public Instance Methods
begin_line()
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 166 def begin_line @begin_line ||= line("begin") end
code()
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 189 def code first_line = start last_line = [ end_line + CONTEXT_LINES, begin_line + MAX_LINES + CONTEXT_LINES, source_buffer.line_count, ].min source_buffer.source.lines[(first_line - 1)..(last_line - 1)].join("") end
end_line()
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 170 def end_line @end_line ||= line("end") end
line_offset()
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 185 def line_offset start - 1 end
start()
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 181 def start [begin_line - CONTEXT_LINES, 1].max end
to_s()
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 174 def to_s [ begin_line, end_line, ].uniq.join("-") end
Private Instance Methods
line(type)
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 203 def line(type) if location["lines"] location["lines"][type] elsif location["positions"] position_to_line(location["positions"][type]) end end
position_to_line(position)
click to toggle source
# File lib/cc/analyzer/formatters/html_formatter.rb, line 211 def position_to_line(position) position["line"] || @source_buffer.decompose_position(position["offset"]).first end