Class: Koota::StringStream Private
- Inherits:
-
Object
- Object
- Koota::StringStream
- Defined in:
- lib/koota/string_stream.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #advance(steps = 1) ⇒ Object private
- #empty? ⇒ Boolean private
- #get ⇒ Object private
- #get_until(*args) ⇒ Object private
-
#initialize(input) ⇒ StringStream
constructor
private
A new instance of StringStream.
- #match?(*args) ⇒ Boolean private
- #peek ⇒ Object private
- #skip(*args) ⇒ Object private
- #skip_until(*args) ⇒ Object private
Constructor Details
#initialize(input) ⇒ StringStream
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of StringStream.
6 7 8 9 |
# File 'lib/koota/string_stream.rb', line 6 def initialize(input) @input = input @pos = 0 end |
Instance Method Details
#advance(steps = 1) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/koota/string_stream.rb', line 23 def advance(steps = 1) @pos += steps end |
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/koota/string_stream.rb', line 11 def empty? @pos >= @input.length end |
#get ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/koota/string_stream.rb', line 19 def get peek.tap { advance } end |
#get_until(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 |
# File 'lib/koota/string_stream.rb', line 42 def get_until(*args) start = @pos skip_until(*args) start == @pos ? nil : @input[start, @pos - start] end |
#match?(*args) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/koota/string_stream.rb', line 27 def match?(*args) args.index(peek) end |
#peek ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/koota/string_stream.rb', line 15 def peek @input[@pos] end |
#skip(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 |
# File 'lib/koota/string_stream.rb', line 31 def skip(*args) index = match?(*args) return unless index advance(args[index].length) end |
#skip_until(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/koota/string_stream.rb', line 38 def skip_until(*args) advance until empty? || match?(*args) end |