Class: Webstract::Screenshot

Inherits:
Object
  • Object
show all
Defined in:
lib/webstract/screenshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Screenshot

Returns a new instance of Screenshot.



6
7
8
9
10
11
12
13
# File 'lib/webstract/screenshot.rb', line 6

def initialize(options = {})
  @handle = Webstract::ScreenCapture.new(options)

  options.each do |k, value|
    setter = "#{k}="
    self.public_send(setter, value) if self.respond_to?(setter)
  end
end

Instance Attribute Details

#accept_languageObject

Returns the value of attribute accept_language.



3
4
5
# File 'lib/webstract/screenshot.rb', line 3

def accept_language
  @accept_language
end

#handleObject (readonly)

Returns the value of attribute handle.



4
5
6
# File 'lib/webstract/screenshot.rb', line 4

def handle
  @handle
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/webstract/screenshot.rb', line 3

def height
  @height
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/webstract/screenshot.rb', line 3

def path
  @path
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/webstract/screenshot.rb', line 3

def url
  @url
end

#user_agentObject

Returns the value of attribute user_agent.



3
4
5
# File 'lib/webstract/screenshot.rb', line 3

def user_agent
  @user_agent
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/webstract/screenshot.rb', line 3

def width
  @width
end

Instance Method Details

#captureObject



15
16
17
# File 'lib/webstract/screenshot.rb', line 15

def capture
  handle.capture(url, path, width: width, height: height, user_agent: user_agent, accept_language: accept_language)
end