Class: LinkThumbnailer::Scraper
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- LinkThumbnailer::Scraper
- Defined in:
- lib/link_thumbnailer/scraper.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(source, url) ⇒ Scraper
constructor
A new instance of Scraper.
Constructor Details
#initialize(source, url) ⇒ Scraper
Returns a new instance of Scraper.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/link_thumbnailer/scraper.rb', line 23 def initialize(source, url) @source = source @url = url @config = ::LinkThumbnailer.page.config @document = parser.call(source) @website = ::LinkThumbnailer::Models::Website.new @website.url = url super(config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
21 22 23 |
# File 'lib/link_thumbnailer/scraper.rb', line 21 def config @config end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
21 22 23 |
# File 'lib/link_thumbnailer/scraper.rb', line 21 def document @document end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
21 22 23 |
# File 'lib/link_thumbnailer/scraper.rb', line 21 def source @source end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
21 22 23 |
# File 'lib/link_thumbnailer/scraper.rb', line 21 def url @url end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
21 22 23 |
# File 'lib/link_thumbnailer/scraper.rb', line 21 def website @website end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/link_thumbnailer/scraper.rb', line 34 def call config.attributes.each do |name| config.scrapers.each do |scraper_prefix| scraper_class(scraper_prefix, name).new(document, website).call(name.to_s) break unless website.send(name).blank? end end website end |