Class: Browserless::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/browserless/options.rb

Constant Summary collapse

HEADER_TEMPLATE =

empty header

"<div></div>"
"<div style='font-size: 11px; margin-left: 40px; font: Helvetica'><span class='pageNumber'></span> of <span class='totalPages'></span></div>"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Options

Returns a new instance of Options.



10
11
12
13
14
15
16
17
18
19
# File 'lib/browserless/options.rb', line 10

def initialize(**options)
  @options = options
  @landscape = config_value(:landscape) || false
  @margin = config_value(:margin) || {}
  @pdf_format = config_value(:format) || "A4"
  @print_background = config_value(:print_background) || false
  @header_template = config_value(:header_template) || HEADER_TEMPLATE
  @footer_template = config_value(:footer_template) || FOOTER_TEMPLATE
  @display_header_footer = config_value(:display_header_footer) || false
end

Instance Attribute Details

Returns the value of attribute display_header_footer.



8
9
10
# File 'lib/browserless/options.rb', line 8

def display_header_footer
  @display_header_footer
end

Returns the value of attribute footer_template.



8
9
10
# File 'lib/browserless/options.rb', line 8

def footer_template
  @footer_template
end

#header_templateObject (readonly)

Returns the value of attribute header_template.



8
9
10
# File 'lib/browserless/options.rb', line 8

def header_template
  @header_template
end

#landscapeObject (readonly)

Returns the value of attribute landscape.



8
9
10
# File 'lib/browserless/options.rb', line 8

def landscape
  @landscape
end

#marginObject (readonly)

Returns the value of attribute margin.



8
9
10
# File 'lib/browserless/options.rb', line 8

def margin
  @margin
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/browserless/options.rb', line 8

def options
  @options
end

#pdf_formatObject (readonly)

Returns the value of attribute pdf_format.



8
9
10
# File 'lib/browserless/options.rb', line 8

def pdf_format
  @pdf_format
end

Returns the value of attribute print_background.



8
9
10
# File 'lib/browserless/options.rb', line 8

def print_background
  @print_background
end

Instance Method Details

#to_hObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/browserless/options.rb', line 21

def to_h
  {
    landscape: landscape,
    displayHeaderFooter: display_header_footer,
    printBackground: print_background,
    margin: margin,
    format: pdf_format,
    headerTemplate: header_template,
    footerTemplate: footer_template
  }
end