Class: Hpricot::Elem
- Inherits:
-
Object
- Object
- Hpricot::Elem
- Defined in:
- lib/hpricot_ext.rb
Instance Attribute Summary collapse
-
#cache_search ⇒ Object
Returns the value of attribute cache_search.
Instance Method Summary collapse
- #_inner_html=(html) ⇒ Object
- #_output ⇒ Object
- #_search ⇒ Object
- #output(out, opts = {}) ⇒ Object
- #search(expr, &block) ⇒ Object
Instance Attribute Details
#cache_search ⇒ Object
Returns the value of attribute cache_search.
4 5 6 |
# File 'lib/hpricot_ext.rb', line 4 def cache_search @cache_search end |
Instance Method Details
#_inner_html=(html) ⇒ Object
19 20 21 |
# File 'lib/hpricot_ext.rb', line 19 def _inner_html=(html) @_inner_html = html end |
#_output ⇒ Object
23 |
# File 'lib/hpricot_ext.rb', line 23 alias :_output :output |
#_search ⇒ Object
5 |
# File 'lib/hpricot_ext.rb', line 5 alias :_search :search |
#output(out, opts = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hpricot_ext.rb', line 24 def output(out, opts={}) if @_inner_html if empty? and ElementContent[@stag.name] == :EMPTY @stag.output(out, opts.merge(:style => :empty)) else @stag.output(out, opts) out << @_inner_html if @etag @etag.output(out, opts) elsif !opts[:preserve] ETag.new(@stag.name).output(out,opts) end end else _output(out,opts) end end |
#search(expr, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/hpricot_ext.rb', line 6 def search(expr,&block) if @_inner_html self.inner_html= @_inner_html @_inner_html = nil end if cache_search @_search ||= {} @_search[expr] || @_search[expr] = _search(expr,&block) else _search(expr,&block) end end |