Class: SGF::CollectionAssembler

Inherits:
Object
  • Object
show all
Defined in:
lib/sgf/collection_assembler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCollectionAssembler

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

#collectionObject (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 message
  collection.errors << message
end

#close_branchObject



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_branchObject



13
14
15
# File 'lib/sgf/collection_assembler.rb', line 13

def open_branch
  @branches.unshift @current_node
end