class PuppetPdf::PdfCreator
Attributes
options[R]
source[R]
Public Class Methods
new(source, options = {})
click to toggle source
# File lib/puppet_pdf/pdf_creator.rb, line 11 def initialize(source, options = {}) validate_yarn_installation @source = source @options = options.tap do |opt| opt[:output_path] = opt.fetch(:output_path, default_output_path) end end
Public Instance Methods
call()
click to toggle source
# File lib/puppet_pdf/pdf_creator.rb, line 20 def call run_yarn(:create_pdf, source, options_json) options[:output_path] end
Private Instance Methods
camelize(string)
click to toggle source
# File lib/puppet_pdf/pdf_creator.rb, line 33 def camelize(string) string_arr = string.to_s.split('_') head, *tail = string_arr head.downcase + tail.map(&:capitalize).join end
default_output_path()
click to toggle source
# File lib/puppet_pdf/pdf_creator.rb, line 40 def default_output_path file = Tempfile.new(["puppet_pdf_#{Time.now.to_i}", '.pdf']) file.path end
options_json()
click to toggle source
# File lib/puppet_pdf/pdf_creator.rb, line 27 def options_json options .each_with_object({}) { |(key, val), opts| opts[camelize(key)] = val } .to_json end