Class: Moxml::C14n::Node
- Inherits:
-
Object
- Object
- Moxml::C14n::Node
- Defined in:
- lib/moxml/c14n/node.rb
Overview
Base class for all C14N data-model nodes. Ported from canon ( lutaml/canon ) — keeps the mature node-set semantics needed for subset canonicalization (spec §3).
Direct Known Subclasses
Moxml::C14n::Nodes::AttributeNode, Moxml::C14n::Nodes::CommentNode, Moxml::C14n::Nodes::ElementNode, Moxml::C14n::Nodes::NamespaceNode, Moxml::C14n::Nodes::ProcessingInstructionNode, Moxml::C14n::Nodes::RootNode, Moxml::C14n::Nodes::TextNode
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #add_child(child) ⇒ Object
- #in_node_set=(value) ⇒ Object
- #in_node_set? ⇒ Boolean
-
#initialize ⇒ Node
constructor
A new instance of Node.
-
#text_content ⇒ Object
Return the text content of this node and all descendants.
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
11 12 13 14 15 |
# File 'lib/moxml/c14n/node.rb', line 11 def initialize @parent = nil @children = [] @in_node_set = true end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/moxml/c14n/node.rb', line 9 def children @children end |
#parent ⇒ Object
Returns the value of attribute parent.
9 10 11 |
# File 'lib/moxml/c14n/node.rb', line 9 def parent @parent end |
Instance Method Details
#add_child(child) ⇒ Object
17 18 19 20 |
# File 'lib/moxml/c14n/node.rb', line 17 def add_child(child) child.parent = self @children << child end |
#in_node_set=(value) ⇒ Object
26 27 28 |
# File 'lib/moxml/c14n/node.rb', line 26 def in_node_set=(value) @in_node_set = value end |
#in_node_set? ⇒ Boolean
22 23 24 |
# File 'lib/moxml/c14n/node.rb', line 22 def in_node_set? @in_node_set end |
#text_content ⇒ Object
Return the text content of this node and all descendants. ElementNode concatenates children's text_content; other nodes (TextNode, CommentNode, etc.) return their value.
33 34 35 |
# File 'lib/moxml/c14n/node.rb', line 33 def text_content children.map(&:text_content).join end |