Class: EasyInvoices::Generator
- Inherits:
-
Object
- Object
- EasyInvoices::Generator
- Defined in:
- lib/easy_invoices/generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(invoice_params, file_name) ⇒ Generator
constructor
A new instance of Generator.
- #process ⇒ Object
Constructor Details
#initialize(invoice_params, file_name) ⇒ Generator
Returns a new instance of Generator.
14 15 16 17 |
# File 'lib/easy_invoices/generator.rb', line 14 def initialize(invoice_params, file_name) @invoice_params = invoice_params @file_name = file_name.nil? ? "#{SecureRandom.hex}.pdf" : "#{file_name}.pdf" end |
Class Method Details
.generate(invoice_params, file_name) ⇒ Object
6 7 8 |
# File 'lib/easy_invoices/generator.rb', line 6 def self.generate(invoice_params, file_name) self.new(invoice_params, file_name).process end |
.storage_dir ⇒ Object
10 11 12 |
# File 'lib/easy_invoices/generator.rb', line 10 def self.storage_dir EasyInvoices.configuration.send(:"#{self.name.demodulize.downcase}_dir") || self::DIR end |
Instance Method Details
#process ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/easy_invoices/generator.rb', line 19 def process check_dir File.open(target_file, 'wb') do |file| file << rendered_pdf end target_file end |