Class: OpenGraphReader::Parser::Graph::Node Private

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content



8
9
10
# File 'lib/open_graph_reader/parser/graph.rb', line 8

def content
  @content
end

#nameObject

Returns the value of attribute name



8
9
10
# File 'lib/open_graph_reader/parser/graph.rb', line 8

def name
  @name
end

#parentNode?

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

#childrenObject

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.

Yields:



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?

#fullnameString

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

#namespaceString

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

#pathArray<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