Class: Hpricot::Attributes
- Inherits:
-
Object
- Object
- Hpricot::Attributes
- Defined in:
- lib/hpricot/tag.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
Returns the value of attribute element.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(e) ⇒ Attributes
constructor
A new instance of Attributes.
- #inspect ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(e) ⇒ Attributes
Returns a new instance of Attributes.
47 48 49 |
# File 'lib/hpricot/tag.rb', line 47 def initialize e @element = e end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
46 47 48 |
# File 'lib/hpricot/tag.rb', line 46 def element @element end |
Instance Method Details
#[](k) ⇒ Object
50 51 52 |
# File 'lib/hpricot/tag.rb', line 50 def [] k Hpricot.uxs((@element.raw_attributes || {})[k]) end |
#[]=(k, v) ⇒ Object
53 54 55 |
# File 'lib/hpricot/tag.rb', line 53 def []= k, v (@element.raw_attributes ||= {})[k] = v.fast_xs end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/hpricot/tag.rb', line 69 def inspect to_hash.inspect end |
#to_hash ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/hpricot/tag.rb', line 56 def to_hash if @element.raw_attributes @element.raw_attributes.inject({}) do |hsh, (k, v)| hsh[k] = Hpricot.uxs(v) hsh end else {} end end |
#to_s ⇒ Object
66 67 68 |
# File 'lib/hpricot/tag.rb', line 66 def to_s to_hash.to_s end |