Class: WeasyPDF::Configuration

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

Constant Summary collapse

DEFAULTS =

Returns:

  • (Hash[Symbol, untyped])
{
  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 =

Returns:

  • (Array[String])
%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_urlString?

Returns the value of attribute base_url.

Returns:

  • (String, nil)


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

def base_url
  @base_url
end

#default_optionsHash[Symbol, untyped]

Returns the value of attribute default_options.

Returns:

  • (Hash[Symbol, untyped])


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

def default_options
  @default_options
end

#exe_pathString

Returns the value of attribute exe_path.

Returns:

  • (String)


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

def exe_path
  @exe_path
end

#temp_pathPathname

Returns the value of attribute temp_path.

Returns:

  • (Pathname)


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

def temp_path
  @temp_path
end

#timeoutInteger

Returns the value of attribute timeout.

Returns:

  • (Integer)


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

def timeout
  @timeout
end

Instance Method Details

#[](key) ⇒ Object

Parameters:

  • key (Symbol)

Returns:

  • (Object)


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

def [](key)
  public_send(key)
end

#[]=(key, value) ⇒ Object

Parameters:

  • key (Symbol)
  • value (Object)

Returns:

  • (Object)


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

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