Class: Billing::Report

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/billing/report.rb

Overview

creates and populates the BIF file

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#billing_itemsObject

Returns the value of attribute billing_items


6
7
8
# File 'app/models/billing/report.rb', line 6

def billing_items
  @billing_items
end

#end_dateObject

Returns the value of attribute end_date


6
7
8
# File 'app/models/billing/report.rb', line 6

def end_date
  @end_date
end

#fieldsObject

Returns the value of attribute fields


6
7
8
# File 'app/models/billing/report.rb', line 6

def fields
  @fields
end

#file_nameObject

Returns the value of attribute file_name


6
7
8
# File 'app/models/billing/report.rb', line 6

def file_name
  @file_name
end

#start_dateObject

Returns the value of attribute start_date


6
7
8
# File 'app/models/billing/report.rb', line 6

def start_date
  @start_date
end

Instance Method Details

#createObject


10
11
12
13
14
# File 'app/models/billing/report.rb', line 10

def create
  f = File.new("#{file_name}.bif", 'w+')
  f.write(data)
  f.close
end

#dataObject


16
17
18
19
20
21
22
# File 'app/models/billing/report.rb', line 16

def data
  ''.tap do |text|
    billing_items.each do |billing_item|
      text << billing_item.to_s(fields)
    end
  end
end