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?, #parse_errors, #parse_errors=, #text_content
Constructor Details
#initialize(name:, value:, namespace_uri: nil, prefix: nil) ⇒ AttributeNode
Returns a new instance of AttributeNode.
10 11 12 13 14 15 16 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 10 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.
8 9 10 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 8 def name @name end |
#namespace_uri ⇒ Object (readonly)
Returns the value of attribute namespace_uri.
8 9 10 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 8 def namespace_uri @namespace_uri end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 8 def prefix @prefix end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 8 def value @value end |
Instance Method Details
#local_name ⇒ Object
22 23 24 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 22 def local_name name end |
#node_info ⇒ Object
50 51 52 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 50 def node_info "name: #{name} value: #{value} namespace_uri: #{namespace_uri} prefix: #{prefix}" end |
#node_type ⇒ Object
18 19 20 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 18 def node_type :attribute end |
#qname ⇒ Object
26 27 28 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 26 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)
36 37 38 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 36 def simple_inheritable? xml_attribute? && ["lang", "space"].include?(name) end |
#xml_attribute? ⇒ Boolean
Check if this is an xml:* attribute
31 32 33 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 31 def xml_attribute? namespace_uri == "http://www.w3.org/XML/1998/namespace" end |
#xml_base? ⇒ Boolean
Check if this is xml:base
46 47 48 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 46 def xml_base? xml_attribute? && name == "base" end |
#xml_id? ⇒ Boolean
Check if this is xml:id
41 42 43 |
# File 'lib/canon/xml/nodes/attribute_node.rb', line 41 def xml_id? xml_attribute? && name == "id" end |