class Panier::Decorators::ReceiptDecorator

Decorates a receipt with presentation-specific methods.

Public Instance Methods

to_csv() click to toggle source

Generates CSV string expressing the details of the receipt.

@return [String] CSV expressing the details of the receipt.

# File lib/panier/decorators/receipt_decorator.rb, line 16
def to_csv
  ::CSV.generate do |csv|
    decorated.line_items.each do |item|
      csv << [item.quantity, " #{item.description}",
              " #{item.total_amount_inc_tax}"]
    end
    csv << []
    csv << ["Sales Taxes: #{total_tax}"]
    csv << ["Total: #{total_amount}"]
  end
end