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
- #file ⇒ Object
- #file_name ⇒ Object
-
#initialize(char_offset: 0, byte_offset: 0, line_location: LineLocation.new) ⇒ ColumnLocation
constructor
A new instance of ColumnLocation.
- #inspect ⇒ Object
- #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.
8 9 10 |
# File 'lib/spellr/column_location.rb', line 8 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
45 46 47 |
# File 'lib/spellr/column_location.rb', line 45 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 |
#file_name ⇒ Object
33 34 35 |
# File 'lib/spellr/column_location.rb', line 33 def file_name line_location.file_name end |
#inspect ⇒ Object
41 42 43 |
# File 'lib/spellr/column_location.rb', line 41 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
37 38 39 |
# File 'lib/spellr/column_location.rb', line 37 def to_s "#{line_location}:#{char_offset}" end |