Class: Selenium::WebDriver::PrintOptions
- Inherits:
-
Object
- Object
- Selenium::WebDriver::PrintOptions
- Defined in:
- lib/selenium/webdriver/common/print_options.rb
Overview
Represents options for printing a page.
Constant Summary collapse
- DEFAULT_SCALE =
1.0
- DEFAULT_ORIENTATION =
'portrait'
- DEFAULT_PAGE_SIZE =
A4 size in cm
{width: 21.0, height: 29.7}.freeze
- DEFAULT_MARGINS =
{top: 1.0, bottom: 1.0, left: 1.0, right: 1.0}.freeze
Instance Attribute Summary collapse
-
#background ⇒ Object
Returns the value of attribute background.
-
#margins ⇒ Object
Returns the value of attribute margins.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#page_ranges ⇒ Object
Returns the value of attribute page_ranges.
-
#page_size ⇒ Hash
Gets the current page size.
-
#scale ⇒ Object
Returns the value of attribute scale.
Instance Method Summary collapse
-
#initialize ⇒ PrintOptions
constructor
A new instance of PrintOptions.
-
#to_h ⇒ Hash
Converts the options to a hash format to be used by WebDriver.
Constructor Details
#initialize ⇒ PrintOptions
Returns a new instance of PrintOptions.
31 32 33 34 35 36 37 38 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 31 def initialize @orientation = DEFAULT_ORIENTATION @scale = DEFAULT_SCALE @background = false @page_ranges = nil @page_size = DEFAULT_PAGE_SIZE @margins = DEFAULT_MARGINS end |
Instance Attribute Details
#background ⇒ Object
Returns the value of attribute background.
29 30 31 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 29 def background @background end |
#margins ⇒ Object
Returns the value of attribute margins.
29 30 31 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 29 def margins @margins end |
#orientation ⇒ Object
Returns the value of attribute orientation.
29 30 31 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 29 def orientation @orientation end |
#page_ranges ⇒ Object
Returns the value of attribute page_ranges.
29 30 31 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 29 def page_ranges @page_ranges end |
#page_size ⇒ Hash
Gets the current page size.
63 64 65 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 63 def page_size @page_size end |
#scale ⇒ Object
Returns the value of attribute scale.
29 30 31 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 29 def scale @scale end |
Instance Method Details
#to_h ⇒ Hash
Converts the options to a hash format to be used by WebDriver.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/selenium/webdriver/common/print_options.rb', line 43 def to_h = { orientation: @orientation, scale: @scale, background: @background, pageRanges: @page_ranges, paperWidth: @page_size[:width], paperHeight: @page_size[:height], marginTop: @margins[:top], marginBottom: @margins[:bottom], marginLeft: @margins[:left], marginRight: @margins[:right] } .compact end |