Class: Webstract::Screenshot
- Inherits:
-
Object
- Object
- Webstract::Screenshot
- Defined in:
- lib/webstract/screenshot.rb
Instance Attribute Summary collapse
-
#accept_language ⇒ Object
Returns the value of attribute accept_language.
-
#basic_auth ⇒ Object
Returns the value of attribute basic_auth.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#height ⇒ Object
Returns the value of attribute height.
-
#path ⇒ Object
Returns the value of attribute path.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #capture ⇒ Object
-
#initialize(options = {}) ⇒ Screenshot
constructor
A new instance of Screenshot.
- #password=(password) ⇒ Object
- #username=(username) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Screenshot
Returns a new instance of Screenshot.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/webstract/screenshot.rb', line 6 def initialize( = {}) @handle = Webstract::ScreenCapture.new() .each do |k, value| setter = "#{k}=" self.public_send(setter, value) if self.respond_to?(setter) end path = [:path] || raise(ArgumentError.new('path required')) @basic_auth ||= {} raise(ArgumentError.new("basic_auth credentials must be a Hash: got #{@basic_auth.inspect}")) unless @basic_auth.is_a?(Hash) end |
Instance Attribute Details
#accept_language ⇒ Object
Returns the value of attribute accept_language.
3 4 5 |
# File 'lib/webstract/screenshot.rb', line 3 def accept_language @accept_language end |
#basic_auth ⇒ Object
Returns the value of attribute basic_auth.
3 4 5 |
# File 'lib/webstract/screenshot.rb', line 3 def basic_auth @basic_auth end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
4 5 6 |
# File 'lib/webstract/screenshot.rb', line 4 def handle @handle end |
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/webstract/screenshot.rb', line 3 def height @height end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/webstract/screenshot.rb', line 4 def path @path end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/webstract/screenshot.rb', line 3 def url @url end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
3 4 5 |
# File 'lib/webstract/screenshot.rb', line 3 def user_agent @user_agent end |
#width ⇒ Object
Returns the value of attribute width.
3 4 5 |
# File 'lib/webstract/screenshot.rb', line 3 def width @width end |
Instance Method Details
#capture ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/webstract/screenshot.rb', line 33 def capture handle.capture(url, path, width: width, height: height, user_agent: user_agent, accept_language: accept_language, basic_auth: basic_auth ) end |
#password=(password) ⇒ Object
29 30 31 |
# File 'lib/webstract/screenshot.rb', line 29 def password=(password) @basic_auth[:password] = password end |
#username=(username) ⇒ Object
25 26 27 |
# File 'lib/webstract/screenshot.rb', line 25 def username=(username) @basic_auth[:username] = username end |