Class: Canon::Xml::Nodes::AttributeNode
- Inherits:
-
Canon::Xml::Node
- Object
- Canon::Xml::Node
- Canon::Xml::Nodes::AttributeNode
- Defined in:
- lib/canon/xml/nodes/attribute_node.rb
Overview
Attribute node in the XPath data model
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace_uri ⇒ Object
readonly
Returns the value of attribute namespace_uri.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Canon::Xml::Node
Instance Method Summary collapse
-
#initialize(name:, value:, namespace_uri: nil, prefix: nil) ⇒ AttributeNode
constructor
A new instance of AttributeNode.
- #local_name ⇒ Object
- #node_info ⇒ Object
- #node_type ⇒ Object
- #qname ⇒ Object
-
#simple_inheritable? ⇒ Boolean
Check if this is a simple inheritable attribute (xml:lang or xml:space).
-
#xml_attribute? ⇒ Boolean
Check if this is an xml:* attribute.
-
#xml_base? ⇒ Boolean
Check if this is xml:base.
-
#xml_id? ⇒ Boolean
Check if this is xml:id.
Methods inherited from Canon::Xml::Node
#add_child, #in_node_set=, #in_node_set?
Constructor Details
#initialize(name:, value:, namespace_uri: nil, prefix: nil) ⇒ AttributeNode
Returns a new instance of AttributeNode.
12 13 14 15 16 17 18 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 12 def initialize(name:, value:, namespace_uri: nil, prefix: nil) super() @name = name @value = value @namespace_uri = namespace_uri @prefix = prefix end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 10 def name @name end |
#namespace_uri ⇒ Object (readonly)
Returns the value of attribute namespace_uri.
10 11 12 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 10 def namespace_uri @namespace_uri end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
10 11 12 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 10 def prefix @prefix end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 10 def value @value end |
Instance Method Details
#local_name ⇒ Object
24 25 26 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 24 def local_name name end |
#node_info ⇒ Object
52 53 54 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 52 def node_info "name: #{name} value: #{value} namespace_uri: #{namespace_uri} prefix: #{prefix}" end |
#node_type ⇒ Object
20 21 22 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 20 def node_type :attribute end |
#qname ⇒ Object
28 29 30 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 28 def qname prefix.nil? || prefix.empty? ? name : "#{prefix}:#{name}" end |
#simple_inheritable? ⇒ Boolean
Check if this is a simple inheritable attribute (xml:lang or xml:space)
38 39 40 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 38 def simple_inheritable? xml_attribute? && ["lang", "space"].include?(name) end |
#xml_attribute? ⇒ Boolean
Check if this is an xml:* attribute
33 34 35 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 33 def xml_attribute? namespace_uri == "http://www.w3.org/XML/1998/namespace" end |
#xml_base? ⇒ Boolean
Check if this is xml:base
48 49 50 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 48 def xml_base? xml_attribute? && name == "base" end |
#xml_id? ⇒ Boolean
Check if this is xml:id
43 44 45 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 43 def xml_id? xml_attribute? && name == "id" end |