Class: GnuCash::Invoice::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/gnucash/invoice/printer.rb

Instance Method Summary collapse

Constructor Details

#initialize(invoice_id) ⇒ Printer

Returns a new instance of Printer.



9
10
11
# File 'lib/gnucash/invoice/printer.rb', line 9

def initialize invoice_id
  @invoice = Invoice.find(invoice_id)
end

Instance Method Details

#embedded_asset(pathname) ⇒ Object



14
15
16
# File 'lib/gnucash/invoice/printer.rb', line 14

def embedded_asset pathname
  environment[pathname].to_s
end

#environmentObject



19
20
21
22
23
24
# File 'lib/gnucash/invoice/printer.rb', line 19

def environment
  @environment ||= Sprockets::Environment.new(template_dir).tap do |env|
    env.append_path 'assets/stylesheets'
    env.css_compressor = :sass
  end
end

#renderObject



27
28
29
30
31
32
33
34
35
# File 'lib/gnucash/invoice/printer.rb', line 27

def render
  template = Slim::Template.new template_dir('invoice.slim').to_s
  template.render(self, {
    :invoice  => @invoice,
    :entries  => @invoice.entries,
    :customer => @invoice.customer,
    :options  => Options
  })
end