Class: Spellr::ColumnLocation
- Inherits:
-
Object
- Object
- Spellr::ColumnLocation
- Defined in:
- lib/spellr/column_location.rb
Instance Attribute Summary collapse
-
#byte_offset ⇒ Object
readonly
Returns the value of attribute byte_offset.
-
#char_offset ⇒ Object
readonly
Returns the value of attribute char_offset.
-
#line_location ⇒ Object
Returns the value of attribute line_location.
Instance Method Summary collapse
- #absolute_byte_offset ⇒ Object
- #absolute_char_offset ⇒ Object
-
#coordinates ⇒ Object
:nocov:.
- #file ⇒ Object
-
#initialize(char_offset: 0, byte_offset: 0, line_location: LineLocation.new) ⇒ ColumnLocation
constructor
A new instance of ColumnLocation.
-
#inspect ⇒ Object
:nocov:.
- #line_number ⇒ Object
- #to_s ⇒ Object
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_offset ⇒ Object (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_offset ⇒ Object (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_location ⇒ Object
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_offset ⇒ Object
21 22 23 |
# File 'lib/spellr/column_location.rb', line 21 def absolute_byte_offset byte_offset + line_location.byte_offset end |
#absolute_char_offset ⇒ Object
17 18 19 |
# File 'lib/spellr/column_location.rb', line 17 def absolute_char_offset char_offset + line_location.char_offset end |
#coordinates ⇒ Object
:nocov:
43 44 45 |
# File 'lib/spellr/column_location.rb', line 43 def coordinates [line_number, char_offset] end |
#file ⇒ Object
29 30 31 |
# File 'lib/spellr/column_location.rb', line 29 def file line_location.file end |
#inspect ⇒ Object
:nocov:
38 39 40 |
# File 'lib/spellr/column_location.rb', line 38 def inspect "#<#{self.class.name} #{self}>" end |
#line_number ⇒ Object
25 26 27 |
# File 'lib/spellr/column_location.rb', line 25 def line_number line_location.line_number end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/spellr/column_location.rb', line 33 def to_s "#{line_location}:#{char_offset}" end |