Class: HTML5::TreeBuilders::Hpricot::Element::AttributeProxy
- Inherits:
-
Object
- Object
- HTML5::TreeBuilders::Hpricot::Element::AttributeProxy
- Defined in:
- lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb
Overview
A call to Hpricot::Elem#raw_attributes is built dynamically, so alterations to the returned value (a hash) will be lost.
AttributeProxy works around this by forwarding :[]= calls to the raw_attributes accessor on the element start tag.
Instance Method Summary collapse
- #[]=(k, v) ⇒ Object
-
#initialize(hpricot) ⇒ AttributeProxy
constructor
A new instance of AttributeProxy.
- #method_missing(*a, &b) ⇒ Object
- #stag_attributes_method ⇒ Object
Constructor Details
#initialize(hpricot) ⇒ AttributeProxy
Returns a new instance of AttributeProxy.
95 96 97 |
# File 'lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb', line 95 def initialize(hpricot) @hpricot = hpricot end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*a, &b) ⇒ Object
108 109 110 |
# File 'lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb', line 108 def method_missing(*a, &b) @hpricot.attributes.send(*a, &b) end |
Instance Method Details
#[]=(k, v) ⇒ Object
99 100 101 |
# File 'lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb', line 99 def []=(k, v) @hpricot.stag.send(stag_attributes_method)[k] = v end |
#stag_attributes_method ⇒ Object
103 104 105 106 |
# File 'lib/feed_tools/vendor/html5/lib/html5/treebuilders/hpricot.rb', line 103 def stag_attributes_method # STag#attributes changed to STag#raw_attributes after Hpricot 0.5 @hpricot.stag.respond_to?(:raw_attributes) ? :raw_attributes : :attributes end |