Method: WkHtml::Converter#initialize

Defined in:
lib/wkhtml/converter.rb

#initialize(data, options = {}) ⇒ Converter

Returns a new instance of Converter.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/wkhtml/converter.rb', line 15

def initialize(data, options = {})
  @data = data
  #Thanks http://stackoverflow.com/questions/800122/best-way-to-convert-strings-to-symbols-in-hash
  @options = options.inject({}){|memo,(k,v)| memo[k.to_s()] = v; memo} #Force string for easy comparison with allowed settings
  
  #Handle multiple inbound types
  @use_data = case @data
  when String
    !(@data =~ CommonSettings::REGEXP_URI)
  when File, Tempfile
    @data = @data.path
    false
  when URI
    @data = @data.to_s()
    false
  else
    false
  end
end