Class: Moxml::C14n::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

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

#childrenObject (readonly)

Returns the value of attribute children.



9
10
11
# File 'lib/moxml/c14n/node.rb', line 9

def children
  @children
end

#parentObject

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

Returns:

  • (Boolean)


22
23
24
# File 'lib/moxml/c14n/node.rb', line 22

def in_node_set?
  @in_node_set
end

#text_contentObject

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