Class: Canon::Xml::Nodes::NamespaceNode
- Inherits:
-
Canon::Xml::Node
- Object
- Canon::Xml::Node
- Canon::Xml::Nodes::NamespaceNode
- Defined in:
- lib/canon/xml/nodes/namespace_node.rb
Overview
Namespace node in the XPath data model
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Attributes inherited from Canon::Xml::Node
Instance Method Summary collapse
- #default_namespace? ⇒ Boolean
-
#initialize(prefix:, uri:) ⇒ NamespaceNode
constructor
A new instance of NamespaceNode.
-
#local_name ⇒ Object
Local name is the prefix (empty string for default namespace).
- #name ⇒ Object
- #node_info ⇒ Object
- #node_type ⇒ Object
-
#xml_namespace? ⇒ Boolean
Check if this is the xml namespace.
Methods inherited from Canon::Xml::Node
#add_child, #in_node_set=, #in_node_set?
Constructor Details
#initialize(prefix:, uri:) ⇒ NamespaceNode
Returns a new instance of NamespaceNode.
12 13 14 15 16 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 12 def initialize(prefix:, uri:) super() @prefix = prefix @uri = uri end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
10 11 12 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 10 def prefix @prefix end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
10 11 12 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 10 def uri @uri end |
Instance Method Details
#default_namespace? ⇒ Boolean
31 32 33 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 31 def default_namespace? prefix.nil? || prefix.empty? end |
#local_name ⇒ Object
Local name is the prefix (empty string for default namespace)
27 28 29 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 27 def local_name prefix.to_s end |
#name ⇒ Object
18 19 20 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 18 def name prefix.to_s end |
#node_info ⇒ Object
40 41 42 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 40 def node_info "prefix: #{prefix} uri: #{uri}" end |
#node_type ⇒ Object
22 23 24 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 22 def node_type :namespace end |
#xml_namespace? ⇒ Boolean
Check if this is the xml namespace
36 37 38 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 36 def xml_namespace? prefix == "xml" && uri == "http://www.w3.org/XML/1998/namespace" end |