Class: GreenOnion::Browser
- Inherits:
-
Object
- Object
- GreenOnion::Browser
- Defined in:
- lib/green_onion/browser.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Browser
constructor
A new instance of Browser.
- #load_driver ⇒ Object
- #snap_screenshot(url, path) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Browser
Returns a new instance of Browser.
6 7 8 9 10 |
# File 'lib/green_onion/browser.rb', line 6 def initialize(params={}) @driver = params[:driver] @dimensions = params[:dimensions] load_driver end |
Instance Attribute Details
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
4 5 6 |
# File 'lib/green_onion/browser.rb', line 4 def dimensions @dimensions end |
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
4 5 6 |
# File 'lib/green_onion/browser.rb', line 4 def driver @driver end |
Instance Method Details
#load_driver ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/green_onion/browser.rb', line 12 def load_driver begin require "green_onion/drivers/#{driver}" @driver_obj = GreenOnion.const_get(@driver.capitalize).new rescue LoadError => e raise e unless e..include?("green_onion/drivers") raise ArgumentError.new("#{@driver} is not supported by GreenOnion.") end end |
#snap_screenshot(url, path) ⇒ Object
22 23 24 |
# File 'lib/green_onion/browser.rb', line 22 def snap_screenshot(url, path) @driver_obj.record(url, path, @dimensions) end |