Class: WriteInvoice::Document

Inherits:
Object
  • Object
show all
Extended by:
Dcmnt, Options, Sections
Defined in:
lib/write_invoice.rb

Class Method Summary collapse

Methods included from Options

get_options, str_difference

Class Method Details

.generate(output: nil, payload: nil, options: {}, debug: true) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/write_invoice.rb', line 44

def self.generate( output: nil, payload: nil, options: {}, debug: true )

  template = Marshal.load( Marshal.dump( get_options ) )
  valid, messages = options_update( options, template, true )

  if valid
    debug ? print( 'Document      ' ) : ''
    pdf = self.document( template, options, payload, output, debug )
    debug ? puts : ''
    debug ? puts( "Pages Total   #{pdf.page_count}" ) : ''

    if output.nil?
      doc = pdf.render
      return doc
    else
      pdf.render_file( output )
      return true
    end

  else
    return messages
  end
end