class Rip::Parser::Location
Attributes
column[R]
length[R]
line[R]
offset[R]
origin[R]
Public Class Methods
from_slice(origin, slice, length = slice.length)
click to toggle source
# File source/rip/parser/location.rb, line 43 def self.from_slice(origin, slice, length = slice.length) new(origin, slice.offset, *slice.line_and_column, length) end
new(origin, offset, line, column, length = 0)
click to toggle source
# File source/rip/parser/location.rb, line 9 def initialize(origin, offset, line, column, length = 0) @origin = origin @offset = offset @line = line @column = column @length = length end
Public Instance Methods
==(other)
click to toggle source
# File source/rip/parser/location.rb, line 17 def ==(other) (origin == other.origin) && (offset == other.offset) end
add_character(count = 1)
click to toggle source
# File source/rip/parser/location.rb, line 22 def add_character(count = 1) self.class.new(origin, offset + count, line, column + count, length) end
add_line(count = 1)
click to toggle source
# File source/rip/parser/location.rb, line 26 def add_line(count = 1) self.class.new(origin, offset + count, line + count, 1, length) end
inspect()
click to toggle source
# File source/rip/parser/location.rb, line 30 def inspect "#<#{self.class.name} #{self}>" end
to_debug()
click to toggle source
# File source/rip/parser/location.rb, line 38 def to_debug offset_length = length.zero? ? offset : (offset..(offset + length - 1)) "#{line}:#{column}(#{offset_length})" end
to_s()
click to toggle source
# File source/rip/parser/location.rb, line 34 def to_s "#{origin}:#{to_debug}" end