Class: Moxml::Attribute
- Inherits:
-
Node
- Object
- Node
- Moxml::Attribute
show all
- Defined in:
- lib/moxml/attribute.rb
Constant Summary
Constants inherited
from Node
Node::TYPES
Instance Attribute Summary
Attributes inherited from Node
#context, #native
Instance Method Summary
collapse
Methods inherited from Node
#add_child, #add_next_sibling, #add_previous_sibling, #at_xpath, #children, #document, #initialize, #next_sibling, #parent, #previous_sibling, #replace, #to_xml, wrap, #xpath
Methods included from XmlUtils
#encode_entities, #normalize_xml_value, #validate_comment_content, #validate_declaration_encoding, #validate_declaration_standalone, #validate_declaration_version, #validate_element_name, #validate_pi_target, #validate_prefix, #validate_uri
Constructor Details
This class inherits a constructor from Moxml::Node
Instance Method Details
#==(other) ⇒ Object
39
40
41
42
43
|
# File 'lib/moxml/attribute.rb', line 39
def ==(other)
return false unless other.is_a?(Attribute)
name == other.name && value == other.value && namespace == other.namespace
end
|
#attribute? ⇒ Boolean
53
54
55
|
# File 'lib/moxml/attribute.rb', line 53
def attribute?
true
end
|
#element ⇒ Object
30
31
32
|
# File 'lib/moxml/attribute.rb', line 30
def element
adapter.attribute_element(@native)
end
|
#name ⇒ Object
5
6
7
|
# File 'lib/moxml/attribute.rb', line 5
def name
@native.name
end
|
#name=(new_name) ⇒ Object
9
10
11
|
# File 'lib/moxml/attribute.rb', line 9
def name=(new_name)
adapter.set_attribute_name(@native, new_name)
end
|
#namespace ⇒ Object
21
22
23
24
|
# File 'lib/moxml/attribute.rb', line 21
def namespace
ns = adapter.namespace(@native)
ns && Namespace.new(ns, context)
end
|
#namespace=(ns) ⇒ Object
26
27
28
|
# File 'lib/moxml/attribute.rb', line 26
def namespace=(ns)
adapter.set_namespace(@native, ns&.native)
end
|
#remove ⇒ Object
34
35
36
37
|
# File 'lib/moxml/attribute.rb', line 34
def remove
adapter.remove_attribute(element, name)
self
end
|
#to_s ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/moxml/attribute.rb', line 45
def to_s
if namespace&.prefix
"#{namespace.prefix}:#{name}=\"#{value}\""
else
"#{name}=\"#{value}\""
end
end
|
#value ⇒ Object
13
14
15
|
# File 'lib/moxml/attribute.rb', line 13
def value
@native.value
end
|
#value=(new_value) ⇒ Object
17
18
19
|
# File 'lib/moxml/attribute.rb', line 17
def value=(new_value)
adapter.set_attribute_value(@native, new_value)
end
|