Class: SGF::CollectionAssembler
- Inherits:
-
Object
- Object
- SGF::CollectionAssembler
- Defined in:
- lib/sgf/collection_assembler.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Method Summary collapse
- #add_error(message) ⇒ Object
- #close_branch ⇒ Object
- #create_node_with_properties(properties) ⇒ Object
-
#initialize ⇒ CollectionAssembler
constructor
A new instance of CollectionAssembler.
- #open_branch ⇒ Object
Constructor Details
#initialize ⇒ CollectionAssembler
Returns a new instance of CollectionAssembler.
7 8 9 10 11 |
# File 'lib/sgf/collection_assembler.rb', line 7 def initialize @collection = SGF::Collection.new @current_node = @collection.root @branches = [] end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/sgf/collection_assembler.rb', line 5 def collection @collection end |
Instance Method Details
#add_error(message) ⇒ Object
28 29 30 |
# File 'lib/sgf/collection_assembler.rb', line 28 def add_error collection.errors << end |
#close_branch ⇒ Object
17 18 19 |
# File 'lib/sgf/collection_assembler.rb', line 17 def close_branch @current_node = @branches.shift end |
#create_node_with_properties(properties) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/sgf/collection_assembler.rb', line 21 def create_node_with_properties properties node = SGF::Node.new @current_node.add_children node @current_node = node @current_node.add_properties properties end |
#open_branch ⇒ Object
13 14 15 |
# File 'lib/sgf/collection_assembler.rb', line 13 def open_branch @branches.unshift @current_node end |