Sha256: 05e1c9f0fd0d608142575912eccef7ad1a1d47afe6ed5256f0defc891c9f6b5d

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

require 'link_thumbnailer/response'
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

1 entries across 1 versions & 1 rubygems

Version Path
link_thumbnailer-3.3.2 lib/link_thumbnailer/page.rb