Class: PageDownloader::Filters::EmbedScript

Inherits:
Object
  • Object
show all
Defined in:
lib/page_downloader/filters/embed_script.rb

Direct Known Subclasses

EmbedStyle

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ EmbedScript



6
7
8
9
# File 'lib/page_downloader/filters/embed_script.rb', line 6

def initialize(options = {})
  @fetcher = options.fetch :fetcher
  @url_resolver = options.fetch :url_resolver
end

Instance Attribute Details

#fetcherObject (readonly)

Returns the value of attribute fetcher.



4
5
6
# File 'lib/page_downloader/filters/embed_script.rb', line 4

def fetcher
  @fetcher
end

Instance Method Details

#filter(content) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/page_downloader/filters/embed_script.rb', line 11

def filter(content)
  content.css("script").select do |script|
    script.attributes["src"]
  end.each do |script|
    embed(script)
  end

  content
end