Class: Polites::Node
- Inherits:
-
Object
- Object
- Polites::Node
- Defined in:
- lib/polites/node.rb
Overview
The Node is the basic building block of the AST we parse Polites document contents into.
Instance Attribute Summary collapse
- #children ⇒ Array<Node> readonly
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(children = []) ⇒ Node
constructor
A new instance of Node.
-
#text ⇒ String
Assemble the text contents of this node and all its children combined.
Constructor Details
#initialize(children = []) ⇒ Node
Returns a new instance of Node.
11 12 13 |
# File 'lib/polites/node.rb', line 11 def initialize(children = []) @children = children end |
Instance Attribute Details
#children ⇒ Array<Node> (readonly)
8 9 10 |
# File 'lib/polites/node.rb', line 8 def children @children end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
22 23 24 |
# File 'lib/polites/node.rb', line 22 def eql?(other) other.is_a?(self.class) && children.eql?(other.children) end |
#text ⇒ String
Assemble the text contents of this node and all its children combined.
18 19 20 |
# File 'lib/polites/node.rb', line 18 def text @children.map(&:text).join end |