Class: Canon::Diff::SourceLocator::LineMap

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#endsObject (readonly)

Returns the value of attribute ends.



22
23
24
# File 'lib/canon/diff/source_locator.rb', line 22

def ends
  @ends
end

#startsObject (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

Returns:

  • (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_countObject



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