Class: Spellr::LineLocation
- Inherits:
-
Object
- Object
- Spellr::LineLocation
- Defined in:
- lib/spellr/line_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.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
Instance Method Summary collapse
- #file_name ⇒ Object
-
#initialize(file = '[String]', line_number = 1, char_offset: 0, byte_offset: 0) ⇒ LineLocation
constructor
A new instance of LineLocation.
- #relative_file_name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file = '[String]', line_number = 1, char_offset: 0, byte_offset: 0) ⇒ LineLocation
Returns a new instance of LineLocation.
10 11 12 13 14 15 |
# File 'lib/spellr/line_location.rb', line 10 def initialize(file = '[String]', line_number = 1, char_offset: 0, byte_offset: 0) @file = file @line_number = line_number @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/line_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/line_location.rb', line 7 def char_offset @char_offset end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/spellr/line_location.rb', line 5 def file @file end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
6 7 8 |
# File 'lib/spellr/line_location.rb', line 6 def line_number @line_number end |
Instance Method Details
#file_name ⇒ Object
21 22 23 |
# File 'lib/spellr/line_location.rb', line 21 def file_name file.respond_to?(:to_path) ? file.to_path : file end |
#relative_file_name ⇒ Object
25 26 27 |
# File 'lib/spellr/line_location.rb', line 25 def relative_file_name Pathname.new(file_name).relative_path_from(Pathname.pwd) end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/spellr/line_location.rb', line 17 def to_s "#{relative_file_name}:#{line_number}" end |