Class: Spellr::LineLocation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = '[String]', line_number = 1, char_offset: 0, byte_offset: 0) ⇒ LineLocation

Returns a new instance of LineLocation.



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

def initialize(file = '[String]', line_number = 1, char_offset: 0, byte_offset: 0)
  @filename = file
  @line_number = line_number
  @char_offset = char_offset
  @byte_offset = byte_offset
end

Instance Attribute Details

#byte_offsetObject (readonly)

Returns the value of attribute byte_offset.



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

def byte_offset
  @byte_offset
end

#char_offsetObject (readonly)

Returns the value of attribute char_offset.



8
9
10
# File 'lib/spellr/line_location.rb', line 8

def char_offset
  @char_offset
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



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

def line_number
  @line_number
end

Instance Method Details

#fileObject



26
27
28
# File 'lib/spellr/line_location.rb', line 26

def file
  @file ||= Spellr::File.wrap(@filename)
end

#file_relative_pathObject



22
23
24
# File 'lib/spellr/line_location.rb', line 22

def file_relative_path
  file.relative_path
end

#to_sObject



18
19
20
# File 'lib/spellr/line_location.rb', line 18

def to_s
  "#{file_relative_path}:#{line_number}"
end