Class: Spellr::ColumnLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/spellr/column_location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(char_offset: 0, byte_offset: 0, line_location: LineLocation.new) ⇒ ColumnLocation

Returns a new instance of ColumnLocation.



11
12
13
14
15
# File 'lib/spellr/column_location.rb', line 11

def initialize(char_offset: 0, byte_offset: 0, line_location: LineLocation.new)
  @line_location = line_location
  @char_offset = char_offset
  @byte_offset = byte_offset
end

Instance Attribute Details

#byte_offsetObject (readonly)

Returns the value of attribute byte_offset.



7
8
9
# File 'lib/spellr/column_location.rb', line 7

def byte_offset
  @byte_offset
end

#char_offsetObject (readonly)

Returns the value of attribute char_offset.



7
8
9
# File 'lib/spellr/column_location.rb', line 7

def char_offset
  @char_offset
end

#line_locationObject

Returns the value of attribute line_location.



9
10
11
# File 'lib/spellr/column_location.rb', line 9

def line_location
  @line_location
end

Instance Method Details

#absolute_byte_offsetObject



21
22
23
# File 'lib/spellr/column_location.rb', line 21

def absolute_byte_offset
  byte_offset + line_location.byte_offset
end

#absolute_char_offsetObject



17
18
19
# File 'lib/spellr/column_location.rb', line 17

def absolute_char_offset
  char_offset + line_location.char_offset
end

#coordinatesObject

:nocov:



43
44
45
# File 'lib/spellr/column_location.rb', line 43

def coordinates
  [line_number, char_offset]
end

#fileObject



29
30
31
# File 'lib/spellr/column_location.rb', line 29

def file
  line_location.file
end

#inspectObject

:nocov:



38
39
40
# File 'lib/spellr/column_location.rb', line 38

def inspect
  "#<#{self.class.name} #{self}>"
end

#line_numberObject



25
26
27
# File 'lib/spellr/column_location.rb', line 25

def line_number
  line_location.line_number
end

#to_sObject



33
34
35
# File 'lib/spellr/column_location.rb', line 33

def to_s
  "#{line_location}:#{char_offset}"
end