Class: Moxml::C14n::Nodes::NamespaceNode

Inherits:
Moxml::C14n::Node show all
Defined in:
lib/moxml/c14n/nodes/namespace_node.rb

Overview

Namespace node. Prefix is empty string for the default namespace.

Instance Attribute Summary collapse

Attributes inherited from Moxml::C14n::Node

#children, #parent

Instance Method Summary collapse

Methods inherited from Moxml::C14n::Node

#add_child, #in_node_set=, #in_node_set?, #text_content

Constructor Details

#initialize(prefix:, uri:) ⇒ NamespaceNode

Returns a new instance of NamespaceNode.



10
11
12
13
14
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 10

def initialize(prefix:, uri:)
  super()
  @prefix = prefix
  @uri = uri
end

Instance Attribute Details

#prefixObject (readonly)

Returns the value of attribute prefix.



8
9
10
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 8

def prefix
  @prefix
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 8

def uri
  @uri
end

Instance Method Details

#default_namespace?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 30

def default_namespace?
  prefix.nil? || prefix.empty?
end

#local_nameObject

Local name is the prefix (empty string for default namespace). Used by ElementNode#sorted_namespace_nodes for sort order.



26
27
28
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 26

def local_name
  prefix.to_s
end

#nameObject



16
17
18
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 16

def name
  prefix.to_s
end

#node_typeObject



20
21
22
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 20

def node_type
  :namespace
end

#xml_namespace?Boolean

The xml namespace is implicit and never rendered.

Returns:

  • (Boolean)


35
36
37
# File 'lib/moxml/c14n/nodes/namespace_node.rb', line 35

def xml_namespace?
  prefix == "xml" && uri == Moxml::C14n::XML_URI
end