Class: Pegex::Input
- Inherits:
-
Object
- Object
- Pegex::Input
- Defined in:
- lib/pegex/input.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#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.
7 8 9 10 11 12 |
# File 'lib/pegex/input.rb', line 7 def initialize @is_eof = false @is_open = false @is_close = false yield self end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/pegex/input.rb', line 5 def file @file end |
#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
27 28 29 30 31 32 33 34 |
# File 'lib/pegex/input.rb', line 27 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
21 22 23 24 25 |
# File 'lib/pegex/input.rb', line 21 def open @buffer = @string \ or fail "Pegex::Input::open failed. No source to open" @is_open = true end |
#open? ⇒ Boolean
36 37 38 |
# File 'lib/pegex/input.rb', line 36 def open? @is_open end |
#read ⇒ Object
14 15 16 17 18 19 |
# File 'lib/pegex/input.rb', line 14 def read buffer = @buffer @buffer = nil @eof = true return buffer end |