Class: JsonToToon::ContainerNode
- Defined in:
- lib/json_to_toon/container_node.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Attributes inherited from DataNode
Instance Method Summary collapse
- #add_child(child) ⇒ Object
-
#initialize(parent = nil) ⇒ ContainerNode
constructor
A new instance of ContainerNode.
- #to_s ⇒ Object
Methods inherited from DataNode
Constructor Details
#initialize(parent = nil) ⇒ ContainerNode
Returns a new instance of ContainerNode.
9 10 11 12 |
# File 'lib/json_to_toon/container_node.rb', line 9 def initialize(parent = nil) super @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
7 8 9 |
# File 'lib/json_to_toon/container_node.rb', line 7 def children @children end |
Instance Method Details
#add_child(child) ⇒ Object
14 15 16 17 18 |
# File 'lib/json_to_toon/container_node.rb', line 14 def add_child(child) raise ArgumentError, 'Can only add objects of type DataNode as children.' unless child.is_a?(DataNode) @children << child end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/json_to_toon/container_node.rb', line 20 def to_s raise NotImplementedError, "#{self.class} must implement the 'to_s' method for specific formatting." end |