Class: UglifyHtml
- Inherits:
-
Object
- Object
- UglifyHtml
- Defined in:
- lib/uglify_html.rb
Instance Method Summary collapse
-
#initialize(html, options = {}) ⇒ UglifyHtml
constructor
A new instance of UglifyHtml.
- #make_ugly ⇒ Object
Constructor Details
#initialize(html, options = {}) ⇒ UglifyHtml
Returns a new instance of UglifyHtml.
4 5 6 7 8 |
# File 'lib/uglify_html.rb', line 4 def initialize(html, = {}) @doc = Hpricot html [:pass_through] ||= [] @options = end |
Instance Method Details
#make_ugly ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/uglify_html.rb', line 10 def make_ugly (@doc/"*").each do |e| next if @options[:pass_through].include? e.name case e.name when 'b', 'strong' then process_with_style(e, "font-weight", "bold") when 'i', 'em' then process_with_style(e, "font-style", "italic") when 'u', 'ins' then process_with_style(e, "text-decoration", "underline") when 'del' then process_with_style(e, "text-decoration", "line-through") when 'ul', 'ol' then process_list(e) end end (@doc/"li ul | li ol").remove @doc.to_html end |