Class: PageMagic::Driver
- Inherits:
-
Object
- Object
- PageMagic::Driver
- Defined in:
- lib/page_magic/driver.rb
Overview
class Driver - instances are factories for drivers used by PageMagic
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#supported_browsers ⇒ Object
readonly
Returns the value of attribute supported_browsers.
Instance Method Summary collapse
-
#build(app, browser:, options: {}) ⇒ Object
Build a new driver instance based on this definition.
-
#initialize(*supported_browsers) {|rack_application, options, browser_name| ... } ⇒ Driver
constructor
Creates a driver definition @yield[rack_application, options, browser_name].
-
#support?(browser) ⇒ Boolean
Determines if the given browser name is supported by this driver definition.
Constructor Details
#initialize(*supported_browsers) {|rack_application, options, browser_name| ... } ⇒ Driver
Creates a driver definition @yield[rack_application, options, browser_name]
18 19 20 21 |
# File 'lib/page_magic/driver.rb', line 18 def initialize(*supported_browsers, &block) @handler = block @supported_browsers = supported_browsers end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
4 5 6 |
# File 'lib/page_magic/driver.rb', line 4 def handler @handler end |
#supported_browsers ⇒ Object (readonly)
Returns the value of attribute supported_browsers.
4 5 6 |
# File 'lib/page_magic/driver.rb', line 4 def supported_browsers @supported_browsers end |
Instance Method Details
#build(app, browser:, options: {}) ⇒ Object
Build a new driver instance based on this definition
28 29 30 |
# File 'lib/page_magic/driver.rb', line 28 def build(app, browser:, options: {}) handler.call(app, , browser) end |
#support?(browser) ⇒ Boolean
Determines if the given browser name is supported by this driver definition
35 36 37 |
# File 'lib/page_magic/driver.rb', line 35 def support?(browser) supported_browsers.include?(browser) end |