Class: Canon::Diff::SourceLocator::LineMap
- Inherits:
-
Object
- Object
- Canon::Diff::SourceLocator::LineMap
- Defined in:
- lib/canon/diff/source_locator.rb
Overview
Line offset map: two flat Integer arrays (starts, ends) — a hash-per-line was one allocation per document line on every enrichment, the presentation stage's quiet constant.
Instance Attribute Summary collapse
-
#ends ⇒ Object
readonly
Returns the value of attribute ends.
-
#starts ⇒ Object
readonly
Returns the value of attribute starts.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #end_at(index) ⇒ Object
-
#initialize(starts, ends) ⇒ LineMap
constructor
A new instance of LineMap.
- #line_count ⇒ Object
- #start_at(index) ⇒ Object
Constructor Details
#initialize(starts, ends) ⇒ LineMap
Returns a new instance of LineMap.
24 25 26 27 |
# File 'lib/canon/diff/source_locator.rb', line 24 def initialize(starts, ends) @starts = starts @ends = ends end |
Instance Attribute Details
#ends ⇒ Object (readonly)
Returns the value of attribute ends.
22 23 24 |
# File 'lib/canon/diff/source_locator.rb', line 22 def ends @ends end |
#starts ⇒ Object (readonly)
Returns the value of attribute starts.
22 23 24 |
# File 'lib/canon/diff/source_locator.rb', line 22 def starts @starts end |
Instance Method Details
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/canon/diff/source_locator.rb', line 29 def empty? @starts.empty? end |
#end_at(index) ⇒ Object
41 42 43 |
# File 'lib/canon/diff/source_locator.rb', line 41 def end_at(index) @ends[index] end |
#line_count ⇒ Object
33 34 35 |
# File 'lib/canon/diff/source_locator.rb', line 33 def line_count @starts.length end |
#start_at(index) ⇒ Object
37 38 39 |
# File 'lib/canon/diff/source_locator.rb', line 37 def start_at(index) @starts[index] end |