Class: Hpricot::Attributes
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.
43 44 45 |
# File 'lib/hpricot/tag.rb', line 43 def initialize e @element = e end |
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
42 43 44 |
# File 'lib/hpricot/tag.rb', line 42 def element @element end |
Instance Method Details
#[](k) ⇒ Object
46 47 48 |
# File 'lib/hpricot/tag.rb', line 46 def [] k Hpricot.uxs((@element.raw_attributes || {})[k]) end |
#[]=(k, v) ⇒ Object
49 50 51 |
# File 'lib/hpricot/tag.rb', line 49 def []= k, v (@element.raw_attributes ||= {})[k] = v.fast_xs end |
#inspect ⇒ Object
65 66 67 |
# File 'lib/hpricot/tag.rb', line 65 def inspect to_hash.inspect end |
#to_hash ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hpricot/tag.rb', line 52 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
62 63 64 |
# File 'lib/hpricot/tag.rb', line 62 def to_s to_hash.to_s end |