Class: Pegex::Input
- Inherits:
-
Object
- Object
- Pegex::Input
- Defined in:
- lib/pegex/input.rb
Instance Attribute Summary collapse
-
#string ⇒ Object
Returns the value of attribute string.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize {|_self| ... } ⇒ Input
constructor
A new instance of Input.
- #open ⇒ Object
- #open? ⇒ Boolean
- #read ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Input
Returns a new instance of Input.
6 7 8 9 10 11 |
# File 'lib/pegex/input.rb', line 6 def initialize @is_eof = false @is_open = false @is_close = false yield self end |
Instance Attribute Details
#string ⇒ Object
Returns the value of attribute string.
4 5 6 |
# File 'lib/pegex/input.rb', line 4 def string @string end |
Instance Method Details
#close ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/pegex/input.rb', line 26 def close fail "Attempted to close an unopen Pegex::Input object" \ if @is_close @is_open = false @is_close = true @buffer = nil return self end |
#open ⇒ Object
20 21 22 23 24 |
# File 'lib/pegex/input.rb', line 20 def open @buffer = @string \ or fail "Pegex::Input::open failed. No source to open" @is_open = true end |
#open? ⇒ Boolean
35 36 37 |
# File 'lib/pegex/input.rb', line 35 def open? @is_open end |
#read ⇒ Object
13 14 15 16 17 18 |
# File 'lib/pegex/input.rb', line 13 def read buffer = @buffer @buffer = nil @eof = true return buffer end |