Class: OpenGraphReader::Parser::Graph::Node Private
- Inherits:
-
Struct
- Object
- Struct
- OpenGraphReader::Parser::Graph::Node
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/open_graph_reader/parser/graph.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A node in the graph.
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Node?
private
The parent node.
Instance Method Summary collapse
-
#<<(node) ⇒ Object
private
Add children.
-
#children ⇒ Object
private
Children of this node.
-
#each {|Node| ... } ⇒ Object
private
Iterate over all children.
-
#empty? ⇒ Bool
Does this node have any children?.
-
#fullname ⇒ String
private
Get node’s full name.
-
#namespace ⇒ String
private
Get node’s namespace.
-
#path ⇒ Array<String>
private
Get node’s namespace as array.
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content
8 9 10 |
# File 'lib/open_graph_reader/parser/graph.rb', line 8 def content @content end |
#name ⇒ Object
Returns the value of attribute name
8 9 10 |
# File 'lib/open_graph_reader/parser/graph.rb', line 8 def name @name end |
#parent ⇒ Node?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The parent node.
15 16 17 |
# File 'lib/open_graph_reader/parser/graph.rb', line 15 def parent @parent end |
Instance Method Details
#<<(node) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add children.
41 42 43 44 |
# File 'lib/open_graph_reader/parser/graph.rb', line 41 def << node node.parent = self children << node end |
#children ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Children of this node.
24 25 26 |
# File 'lib/open_graph_reader/parser/graph.rb', line 24 def children @children ||= [] end |
#each {|Node| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Iterate over all children.
31 32 33 34 35 36 |
# File 'lib/open_graph_reader/parser/graph.rb', line 31 def each(&block) children.each do |child| yield child child.each(&block) end end |
#empty? ⇒ Bool
Does this node have any children?
21 |
# File 'lib/open_graph_reader/parser/graph.rb', line 21 def_delegators :children, :empty? |
#fullname ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get node’s full name.
63 64 65 66 |
# File 'lib/open_graph_reader/parser/graph.rb', line 63 def fullname @fullname ||= [namespace, name].compact.join(":") @fullname unless @fullname.empty? end |
#namespace ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get node’s namespace.
49 50 51 |
# File 'lib/open_graph_reader/parser/graph.rb', line 49 def namespace parent.fullname if parent end |
#path ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get node’s namespace as array.
56 57 58 |
# File 'lib/open_graph_reader/parser/graph.rb', line 56 def path @path ||= fullname.split(":") end |