Class: BillTrap::Adapters::Ooffice

Inherits:
Object
  • Object
show all
Includes:
Helpers, Serenity::Generator
Defined in:
lib/billtrap/adapters/ooffice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#format_date, #format_money, #is_i?

Methods included from Serenity::Generator

#render_odt

Constructor Details

#initialize(attributes) ⇒ Ooffice

Returns a new instance of Ooffice.



9
10
11
12
13
14
# File 'lib/billtrap/adapters/ooffice.rb', line 9

def initialize attributes
  attributes.each do |key, val|
    # slurp attributes into instances variables
    instance_variable_set("@#{key}", val)
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/billtrap/adapters/ooffice.rb', line 7

def id
  @id
end

Instance Method Details

#generateObject



16
17
18
19
20
21
22
23
# File 'lib/billtrap/adapters/ooffice.rb', line 16

def generate
    date = @invoice[:created]
    output_path = "#{Config['billtrap_archive']}/#{date.year}/#{date.month}/#{date.mday}"
    FileUtils.mkpath(output_path)

    render_odt Config['serenity_template'], "#{output_path}/#{@invoice.id}.odt"
    puts "Generated invoice has been output to: #{output_path}/#{@invoice.id}.odt"
end