Class: XmlUtils::Attribute
- Inherits:
-
Object
- Object
- XmlUtils::Attribute
- Defined in:
- lib/xmlutils/node.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
Returns the value of attribute element.
-
#name ⇒ Object
Returns the value of attribute name.
-
#normalized ⇒ Object
Returns the value of attribute normalized.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #clone ⇒ Object
-
#initialize(name, value, normalized = true) ⇒ Attribute
constructor
A new instance of Attribute.
- #namespace ⇒ Object
- #node_type ⇒ Object
- #prefix ⇒ Object
- #to_s ⇒ Object
- #to_string ⇒ Object
Constructor Details
#initialize(name, value, normalized = true) ⇒ Attribute
Returns a new instance of Attribute.
304 305 306 307 308 309 |
# File 'lib/xmlutils/node.rb', line 304 def initialize(name, value, normalized = true) @name = name.to_s @value = normalized ? value.to_s : normalize(value.to_s) @normalized = normalized @element = nil end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
302 303 304 |
# File 'lib/xmlutils/node.rb', line 302 def element @element end |
#name ⇒ Object
Returns the value of attribute name.
302 303 304 |
# File 'lib/xmlutils/node.rb', line 302 def name @name end |
#normalized ⇒ Object
Returns the value of attribute normalized.
302 303 304 |
# File 'lib/xmlutils/node.rb', line 302 def normalized @normalized end |
#value ⇒ Object
Returns the value of attribute value.
302 303 304 |
# File 'lib/xmlutils/node.rb', line 302 def value @value end |
Instance Method Details
#clone ⇒ Object
315 316 317 |
# File 'lib/xmlutils/node.rb', line 315 def clone Attribute.new(@name, @value, true) end |
#namespace ⇒ Object
327 328 329 330 |
# File 'lib/xmlutils/node.rb', line 327 def namespace prefix = @name.include?(':') ? @name.split(':').first : '' prefix == 'xmlns' ? '' : prefix end |
#node_type ⇒ Object
311 312 313 |
# File 'lib/xmlutils/node.rb', line 311 def node_type :attribute end |
#prefix ⇒ Object
332 333 334 |
# File 'lib/xmlutils/node.rb', line 332 def prefix @name.include?(':') ? @name.split(':').first : '' end |
#to_s ⇒ Object
319 320 321 |
# File 'lib/xmlutils/node.rb', line 319 def to_s @value end |
#to_string ⇒ Object
323 324 325 |
# File 'lib/xmlutils/node.rb', line 323 def to_string "#{@name}=\"#{escape(@value)}\"" end |