Class: Taurus::XML::Attr
- Inherits:
-
Object
- Object
- Taurus::XML::Attr
- Defined in:
- lib/taurus/xml/attr.rb
Overview
Lightweight attribute wrapper. libtaurus v0.4.4 doesn't expose per-attribute pointers (no TaurusAttribute accessors in the public API), so an Attr is a (name, value, parent_element) triple. Mutation goes through the parent element via #[]. Once upstream adds attribute-level accessors, this can become a pointer-backed wrapper.
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, value, element) ⇒ Attr
constructor
A new instance of Attr.
- #inspect ⇒ Object
- #namespace ⇒ Object
- #remove ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(name, value, element) ⇒ Attr
Returns a new instance of Attr.
12 13 14 15 16 |
# File 'lib/taurus/xml/attr.rb', line 12 def initialize(name, value, element) @name = name @value = value @element = element end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
10 11 12 |
# File 'lib/taurus/xml/attr.rb', line 10 def element @element end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/taurus/xml/attr.rb', line 10 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/taurus/xml/attr.rb', line 10 def value @value end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 37 38 |
# File 'lib/taurus/xml/attr.rb', line 34 def ==(other) other.is_a?(Taurus::XML::Attr) && @name == other.name && @value == other.value && @element == other.element end |
#inspect ⇒ Object
40 41 42 |
# File 'lib/taurus/xml/attr.rb', line 40 def inspect "#<#{self.class.name} name=#{@name.inspect} value=#{@value.inspect}>" end |
#namespace ⇒ Object
23 24 25 |
# File 'lib/taurus/xml/attr.rb', line 23 def namespace nil # upstream gap: per-attribute namespace not exposed end |
#remove ⇒ Object
27 28 29 |
# File 'lib/taurus/xml/attr.rb', line 27 def remove @element.remove_attribute(@name) end |
#to_s ⇒ Object
31 |
# File 'lib/taurus/xml/attr.rb', line 31 def to_s; @value; end |
#to_str ⇒ Object
32 |
# File 'lib/taurus/xml/attr.rb', line 32 def to_str; @value; end |