Class: WeasyPDF::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/weasy_pdf/configuration.rb

Constant Summary collapse

DEFAULTS =
{
  page_size: "A4",
  orientation: "Portrait",
  margin_top: "10mm",
  margin_bottom: "10mm",
  margin_left: "10mm",
  margin_right: "10mm",
  encoding: "utf-8",
  zoom: 1,
  media_type: "print" # WeasyPrint defaults to 'screen'; 'print' activates @media print rules
}.freeze
BINARY_CANDIDATES =
%w[
  /usr/local/bin/weasyprint
  /usr/bin/weasyprint
  /opt/weasyprint/bin/weasyprint
  /opt/homebrew/bin/weasyprint
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



26
27
28
29
30
31
32
# File 'lib/weasy_pdf/configuration.rb', line 26

def initialize
  @exe_path = find_binary
  @default_options = DEFAULTS.dup
  @base_url = nil
  @timeout = 60
  @temp_path = default_temp_path
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



24
25
26
# File 'lib/weasy_pdf/configuration.rb', line 24

def base_url
  @base_url
end

#default_optionsObject

Returns the value of attribute default_options.



24
25
26
# File 'lib/weasy_pdf/configuration.rb', line 24

def default_options
  @default_options
end

#exe_pathObject

Returns the value of attribute exe_path.



24
25
26
# File 'lib/weasy_pdf/configuration.rb', line 24

def exe_path
  @exe_path
end

#temp_pathObject

Returns the value of attribute temp_path.



24
25
26
# File 'lib/weasy_pdf/configuration.rb', line 24

def temp_path
  @temp_path
end

#timeoutObject

Returns the value of attribute timeout.



24
25
26
# File 'lib/weasy_pdf/configuration.rb', line 24

def timeout
  @timeout
end

Instance Method Details

#[](key) ⇒ Object



34
35
36
# File 'lib/weasy_pdf/configuration.rb', line 34

def [](key)
  public_send(key)
end

#[]=(key, value) ⇒ Object



38
39
40
# File 'lib/weasy_pdf/configuration.rb', line 38

def []=(key, value)
  public_send(:"#{key}=", value)
end