Class: ABNF::Stream
- Inherits:
-
Object
- Object
- ABNF::Stream
- Defined in:
- lib/abnf.rb
Instance Attribute Summary collapse
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
Instance Method Summary collapse
- #clip(start) ⇒ Object
- #first ⇒ Object
-
#initialize(s, full = nil, pos = 0) ⇒ Stream
constructor
A new instance of Stream.
- #rest ⇒ Object
Constructor Details
#initialize(s, full = nil, pos = 0) ⇒ Stream
Returns a new instance of Stream.
33 34 35 36 37 |
# File 'lib/abnf.rb', line 33 def initialize(s, full = nil, pos = 0) @s = s @full = full.nil? ? s : full @pos = pos end |
Instance Attribute Details
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
31 32 33 |
# File 'lib/abnf.rb', line 31 def pos @pos end |
Instance Method Details
#clip(start) ⇒ Object
47 48 49 |
# File 'lib/abnf.rb', line 47 def clip(start) @full[start...@pos] end |
#first ⇒ Object
39 40 41 |
# File 'lib/abnf.rb', line 39 def first @s[0].ord if @s[0] end |