Class: CC::Analyzer::Formatters::HTMLFormatter::Location
- Inherits:
-
Object
- Object
- CC::Analyzer::Formatters::HTMLFormatter::Location
- Defined in:
- lib/cc/analyzer/formatters/html_formatter.rb
Constant Summary collapse
- CONTEXT_LINES =
2
- MAX_LINES =
10
Instance Method Summary collapse
- #begin_line ⇒ Object
- #code ⇒ Object
- #end_line ⇒ Object
-
#initialize(source_buffer, location) ⇒ Location
constructor
A new instance of Location.
- #line_offset ⇒ Object
- #start ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(source_buffer, location) ⇒ Location
Returns a new instance of Location.
161 162 163 164 |
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 161 def initialize(source_buffer, location) @source_buffer = source_buffer @location = location end |
Instance Method Details
#begin_line ⇒ Object
166 167 168 |
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 166 def begin_line @begin_line ||= line("begin") end |
#code ⇒ Object
189 190 191 192 193 194 195 196 197 |
# 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 ⇒ Object
170 171 172 |
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 170 def end_line @end_line ||= line("end") end |
#line_offset ⇒ Object
185 186 187 |
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 185 def line_offset start - 1 end |
#start ⇒ Object
181 182 183 |
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 181 def start [begin_line - CONTEXT_LINES, 1].max end |
#to_s ⇒ Object
174 175 176 177 178 179 |
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 174 def to_s [ begin_line, end_line, ].uniq.join("-") end |