Sha256: d3cecb2b6b3c4c71bdc088fe61e38f37bb0eaf235c17e327b14abe527e7ed440

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

require 'screencap'
# require 'smartshot'

module YAMG
  #
  # Screenshot from multiple providers
  #
  class Screenshot
    attr_accessor :url, :size, :command

    # Uses PhantomJS
    def initialize(ss)
      @name, opts =  *ss
      uri = URI.parse(opts['url'])
      @url = "http://#{uri}"
      @size = opts['size'].split(/\s?,\s?/)
      # @fetcher = Smartshot::Screenshot.new(window_size: @size)
      @fetcher = Screencap::Fetcher.new(@url)
    end

    # Take the screenshot
    # Do we need pixel depth??
    def work(path)
      # visit(url)
      # page.save_screenshot("#{path}/#{@name}.png")
      # @fetcher.take_screenshot!(url: url, output: "#{path}/#{@name}.png")
      @fetcher.fetch(output: "#{path}/#{@name}.png", width: @size[0], height: @size[1])
      puts Rainbow("SS #{url} #{size}").black
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yamg-0.0.9 lib/yamg/screenshot.rb