class Aerospike::Utils::StringParser

Attributes

io[R]

Public Class Methods

new(str) click to toggle source
# File lib/aerospike/utils/string_parser.rb, line 25
def initialize(str)
  @io = ::StringIO.new(str)
end

Public Instance Methods

current() click to toggle source
# File lib/aerospike/utils/string_parser.rb, line 29
def current
  @io.string[@io.tell]
end
expect(char) click to toggle source

Reads next character and raise if not matching desired one

# File lib/aerospike/utils/string_parser.rb, line 34
def expect(char)
  raise ::Aerospike::Exceptions::Parse unless @io.read(1) == char
end
prev() click to toggle source
# File lib/aerospike/utils/string_parser.rb, line 48
def prev
  @io.string[@io.tell - 1]
end
read_until(*args) click to toggle source
# File lib/aerospike/utils/string_parser.rb, line 38
def read_until(*args)
  [].tap do |result|
    loop do
      chr = @io.read(1)
      break if args.include?(chr)
      result << chr
    end
  end.join
end
step(count = 1) click to toggle source
# File lib/aerospike/utils/string_parser.rb, line 52
def step(count = 1)
  @io.read(count)
end