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
private
Does this node have any content or non-empty children?.
-
#fullname ⇒ String
private
Get node’s full name.
- #inspect ⇒ Object (also: #to_s) private
-
#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.
42 43 44 45 |
# File 'lib/open_graph_reader/parser/graph.rb', line 42 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.
25 26 27 |
# File 'lib/open_graph_reader/parser/graph.rb', line 25 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.
32 33 34 35 36 37 |
# File 'lib/open_graph_reader/parser/graph.rb', line 32 def each(&block) children.each do |child| yield child child.each(&block) end end |
#empty? ⇒ Bool
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.
Does this node have any content or non-empty children?
20 21 22 |
# File 'lib/open_graph_reader/parser/graph.rb', line 20 def empty? content.nil? && (children.empty? || children.all?(&:empty?)) end |
#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.
64 65 66 67 |
# File 'lib/open_graph_reader/parser/graph.rb', line 64 def fullname @fullname ||= [namespace, name].compact.join(":") @fullname unless @fullname.empty? end |
#inspect ⇒ Object Also known as: to_s
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.
69 70 71 |
# File 'lib/open_graph_reader/parser/graph.rb', line 69 def inspect "#{super.chop} children=#{children.inspect}>" 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.
50 51 52 |
# File 'lib/open_graph_reader/parser/graph.rb', line 50 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.
57 58 59 |
# File 'lib/open_graph_reader/parser/graph.rb', line 57 def path @path ||= fullname.split(":") end |