Sha256: d8b4052d87675d3ae6ec911aa9e416342a4f6c0d107d61ee5ee5d9dbc2453970
Contents?: true
Size: 747 Bytes
Versions: 3
Compression:
Stored size: 747 Bytes
Contents
# frozen_string_literal: true module Koota # @api private class StringStream def initialize(input) @input = input @pos = 0 end def empty? @pos >= @input.length end def peek @input[@pos] end def get peek.tap { advance } end def advance(steps = 1) @pos += steps end def match?(*args) args.index(peek) end def skip(*args) index = match?(*args) return unless index advance(args[index].length) end def skip_until(*args) advance until empty? || match?(*args) end def get_until(*args) start = @pos skip_until(*args) start == @pos ? nil : @input[start, @pos - start] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
koota-0.6.1 | lib/koota/string_stream.rb |
koota-0.6.0 | lib/koota/string_stream.rb |
koota-0.5.0 | lib/koota/string_stream.rb |