Sha256: 3aa5d9551e79c7c03fa58d8efb0604f0d9f5e459c5777856e049a68f0f8e4e97

Contents?: true

Size: 700 Bytes

Versions: 29

Compression:

Stored size: 700 Bytes

Contents

require 'link_thumbnailer/processor'
require 'link_thumbnailer/scraper'

module LinkThumbnailer
  class Page

    attr_reader :url, :options, :source

    def initialize(url, options = {})
      @url     = url
      @options = options

      set_options
    end

    def generate
      @source = processor.call(url)
      scraper.call
    end

    def config
      @config ||= ::LinkThumbnailer.config.dup
    end

    private

    def set_options
      options.each { |k, v| config.send("#{k}=", v) }
    end

    def processor
      @processor ||= ::LinkThumbnailer::Processor.new
    end

    def scraper
      @scraper ||= ::LinkThumbnailer::Scraper.new(source, processor.url)
    end

  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
link_thumbnailer-3.3.0 lib/link_thumbnailer/page.rb
link_thumbnailer-3.2.1 lib/link_thumbnailer/page.rb
link_thumbnailer-3.2.0 lib/link_thumbnailer/page.rb
link_thumbnailer-3.1.2 lib/link_thumbnailer/page.rb
link_thumbnailer-3.1.1 lib/link_thumbnailer/page.rb
link_thumbnailer-3.1.0 lib/link_thumbnailer/page.rb
link_thumbnailer-3.0.3 lib/link_thumbnailer/page.rb
link_thumbnailer-3.0.2 lib/link_thumbnailer/page.rb
link_thumbnailer-3.0.1 lib/link_thumbnailer/page.rb
link_thumbnailer-3.0.0 lib/link_thumbnailer/page.rb
link_thumbnailer-2.6.1 lib/link_thumbnailer/page.rb
link_thumbnailer-2.6.0 lib/link_thumbnailer/page.rb
link_thumbnailer-2.5.2 lib/link_thumbnailer/page.rb
link_thumbnailer-2.5.1 lib/link_thumbnailer/page.rb
link_thumbnailer-2.5.0 lib/link_thumbnailer/page.rb
link_thumbnailer-2.4.0 lib/link_thumbnailer/page.rb
link_thumbnailer-2.3.2 lib/link_thumbnailer/page.rb
link_thumbnailer-2.3.1 lib/link_thumbnailer/page.rb
link_thumbnailer-2.3.0 lib/link_thumbnailer/page.rb
link_thumbnailer-2.2.3 lib/link_thumbnailer/page.rb