class Spellr::Token
Attributes
line[R]
location[R]
replacement[R]
Public Class Methods
new(string, line: string, location: ColumnLocation.new)
click to toggle source
Calls superclass method
# File lib/spellr/token.rb, line 20 def initialize(string, line: string, location: ColumnLocation.new) @location = location @line = line super(string) end
Public Instance Methods
byte_range()
click to toggle source
# File lib/spellr/token.rb, line 42 def byte_range # leftovers:allow i don't want to delete this @byte_range ||= location.byte_offset...(location.byte_offset + bytesize) end
char_range()
click to toggle source
:nocov:
# File lib/spellr/token.rb, line 37 def char_range @char_range ||= location.char_offset...(location.char_offset + length) end
coordinates()
click to toggle source
# File lib/spellr/token.rb, line 57 def coordinates location.coordinates end
file_byte_range()
click to toggle source
# File lib/spellr/token.rb, line 52 def file_byte_range # leftovers:allow i don't want to delete this @file_byte_range ||= location.absolute_byte_offset...(location.absolute_byte_offset + bytesize) end
file_char_range()
click to toggle source
# File lib/spellr/token.rb, line 47 def file_char_range @file_char_range ||= location.absolute_char_offset...(location.absolute_char_offset + length) end
highlight(range = char_range)
click to toggle source
# File lib/spellr/token.rb, line 61 def highlight(range = char_range) "#{slice(0...(range.first))}#{Spellr::StringFormat.red slice(range)}#{slice(range.last..-1)}" end
inspect()
click to toggle source
:nocov:
# File lib/spellr/token.rb, line 32 def inspect "#<#{self.class.name} #{to_s.inspect} @#{location}>" end
line=(new_line)
click to toggle source
# File lib/spellr/token.rb, line 26 def line=(new_line) @line = new_line location.line_location = new_line.location.line_location end
replace(replacement)
click to toggle source
# File lib/spellr/token.rb, line 65 def replace(replacement) @replacement = replacement location.file.insert(replacement, file_char_range) end