Class: Ruty::Datastructure::NodeStream
- Inherits:
-
Object
- Object
- Ruty::Datastructure::NodeStream
- Defined in:
- lib/ruty/datastructure.rb
Overview
stream class. Some kind of write only array which just accepts nodes and can be converted into a nodelist afterwards.
Instance Method Summary collapse
-
#<<(node) ⇒ Object
add a new node to the stream.
-
#initialize(parser) ⇒ NodeStream
constructor
A new instance of NodeStream.
-
#to_nodelist ⇒ Object
convert the streamed data into a nodelist.
Constructor Details
#initialize(parser) ⇒ NodeStream
Returns a new instance of NodeStream.
78 79 80 81 82 |
# File 'lib/ruty/datastructure.rb', line 78 def initialize parser @parser = parser @stream = [] @nodelist = nil end |
Instance Method Details
#<<(node) ⇒ Object
add a new node to the stream
85 86 87 88 |
# File 'lib/ruty/datastructure.rb', line 85 def << node raise RuntimeError, 'cannot write to closed stream' if @nodelist @stream << node end |