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?, #parse_errors, #parse_errors=, #text_content
Constructor Details
#initialize(prefix:, uri:) ⇒ NamespaceNode
Returns a new instance of NamespaceNode.
10 11 12 13 14 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 10 def initialize(prefix:, uri:) super() @prefix = prefix @uri = uri end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 8 def prefix @prefix end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
8 9 10 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 8 def uri @uri end |
Instance Method Details
#default_namespace? ⇒ Boolean
29 30 31 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 29 def default_namespace? prefix.nil? || prefix.empty? end |
#local_name ⇒ Object
Local name is the prefix (empty string for default namespace)
25 26 27 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 25 def local_name prefix.to_s end |
#name ⇒ Object
16 17 18 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 16 def name prefix.to_s end |
#node_info ⇒ Object
38 39 40 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 38 def node_info "prefix: #{prefix} uri: #{uri}" end |
#node_type ⇒ Object
20 21 22 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 20 def node_type :namespace end |
#xml_namespace? ⇒ Boolean
Check if this is the xml namespace
34 35 36 |
# File 'lib/canon/xml/nodes/namespace_node.rb', line 34 def xml_namespace? prefix == "xml" && uri == "http://www.w3.org/XML/1998/namespace" end |