Parent

Class/Module Index [+]

Quicksearch

RKelly::CharPos

Represents a character position in source code.

It’s a value object - it can’t be modified.

Constants

EMPTY

A re-usable empty position

Attributes

char[R]
index[R]
line[R]

Public Class Methods

new(line, char, index) click to toggle source
# File lib/rkelly/char_pos.rb, line 9
def initialize(line, char, index)
  @line = line
  @char = char
  @index = index
end

Public Instance Methods

inspect() click to toggle source
Alias for: to_s
next(string) click to toggle source

Creates a new character position that’s a given string away from this one.

# File lib/rkelly/char_pos.rb, line 17
def next(string)
  if string.include?("\n")
    lines = string.split(/\n/, -1)
    CharPos.new(@line + lines.length - 1, lines.last.length, @index + string.length)
  else
    CharPos.new(@line, @char + string.length, @index + string.length)
  end
end
to_s() click to toggle source
# File lib/rkelly/char_pos.rb, line 26
def to_s
  "{line:#{@line} char:#{@char} (#{@index})}"
end
Also aliased as: inspect

[Validate]

Generated with the Darkfish Rdoc Generator 2.