lib/aerospike/utils/string_parser.rb in aerospike-2.6.0 vs lib/aerospike/utils/string_parser.rb in aerospike-2.7.0

- old
+ new

@@ -19,10 +19,11 @@ module Aerospike module Utils class StringParser attr_reader :io + def initialize(str) @io = ::StringIO.new(str) end def current @@ -32,22 +33,25 @@ # Reads next character and raise if not matching desired one def expect(char) raise ::Aerospike::Exceptions::Parse unless @io.read(1) == char end - def read_until(char) + def read_until(*args) [].tap do |result| loop do chr = @io.read(1) - break if chr == char + break if args.include?(chr) result << chr end end.join end + def prev + @io.string[@io.tell - 1] + end + def step(count = 1) @io.read(count) end - end end end