class PageDownloader::Filters::EmbedStyle
Public Instance Methods
filter(content)
click to toggle source
# File lib/page_downloader/filters/embed_style.rb, line 4 def filter(content) content.css("link").select do |link| stylesheet?(link) end.each do |link| embed(link) end content end
Private Instance Methods
embed(link)
click to toggle source
# File lib/page_downloader/filters/embed_style.rb, line 21 def embed(link) content = fetch_content(link.attributes["href"].value) html = "<style>#{content}</style>" link.parent.add_child(html) link.remove end
stylesheet?(link)
click to toggle source
# File lib/page_downloader/filters/embed_style.rb, line 16 def stylesheet?(link) rel = link.attributes["rel"] rel && rel.value.downcase == "stylesheet" end