Class: WickedPdf::OptionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/wicked_pdf/option_parser.rb

Constant Summary collapse

BINARY_VERSION_WITHOUT_DASHES =
Gem::Version.new('0.12.0')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(binary_version = WickedPdf::DEFAULT_BINARY_VERSION) ⇒ OptionParser

Returns a new instance of OptionParser.



7
8
9
# File 'lib/wicked_pdf/option_parser.rb', line 7

def initialize(binary_version = WickedPdf::DEFAULT_BINARY_VERSION)
  @binary_version = binary_version
end

Instance Attribute Details

#binary_versionObject (readonly)

Returns the value of attribute binary_version.



5
6
7
# File 'lib/wicked_pdf/option_parser.rb', line 5

def binary_version
  @binary_version
end

#hf_tempfilesObject (readonly)

Returns the value of attribute hf_tempfiles.



5
6
7
# File 'lib/wicked_pdf/option_parser.rb', line 5

def hf_tempfiles
  @hf_tempfiles
end

Instance Method Details

#parse(options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wicked_pdf/option_parser.rb', line 11

def parse(options)
  [
    parse_extra(options),
    parse_others(options),
    parse_global(options),
    parse_outline(options.delete(:outline)),
    parse_header_footer(:header => options.delete(:header),
                        :footer => options.delete(:footer),
                        :layout => options[:layout]),
    parse_cover(options.delete(:cover)),
    parse_toc(options.delete(:toc)),
    parse_basic_auth(options)
  ].flatten
end

#valid_option(name) ⇒ Object



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

def valid_option(name)
  if binary_version < BINARY_VERSION_WITHOUT_DASHES
    "--#{name}"
  else
    name
  end
end