class Zenithal::StringReader

Attributes

columnno[R]
lineno[R]
string[R]

Public Class Methods

new(string) click to toggle source
# File source/zenml/reader.rb, line 10
def initialize(string)
  @string = string
  @chars = string.chars
  @pos = -1
  @lineno = 1
  @columnno = 1
end

Public Instance Methods

mark() click to toggle source
# File source/zenml/reader.rb, line 34
def mark
  return [@pos, @lineno, @columnno]
end
peek() click to toggle source
# File source/zenml/reader.rb, line 29
def peek
  char = @chars[@pos + 1]
  return char
end
read() click to toggle source
# File source/zenml/reader.rb, line 18
def read
  @pos += 1
  @columnno += 1
  char = @chars[@pos]
  if char == "\n"
    @lineno += 1
    @columnno = 1
  end
  return char
end
reset(mark) click to toggle source
# File source/zenml/reader.rb, line 38
def reset(mark)
  @pos = mark[0]
  @lineno = mark[1]
  @columnno = mark[2]
end