Class: Slimmer::TitleInserter
- Inherits:
-
Object
- Object
- Slimmer::TitleInserter
- Defined in:
- lib/slimmer.rb
Instance Method Summary collapse
Instance Method Details
#filter(src, dest) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/slimmer.rb', line 138 def filter(src,dest) title = src.at_css('head title') head = dest.at_xpath('/html/head') if head && title insert_title(title,head) end end |
#insert_title(title, head) ⇒ Object
146 147 148 149 150 151 152 |
# File 'lib/slimmer.rb', line 146 def insert_title(title, head) if head.at_css('title').nil? head.first_element_child.nil? ? head << title : head.first_element_child.before(title) else head.at_css('title').replace(title) end end |