Class: Panier::Decorators::ReceiptDecorator
- Inherits:
-
Object
- Object
- Panier::Decorators::ReceiptDecorator
- Includes:
- Decorator
- Defined in:
- lib/panier/decorators/receipt_decorator.rb
Overview
Decorates a receipt with presentation-specific methods.
Instance Attribute Summary
Attributes included from Decorator
Instance Method Summary collapse
-
#to_csv ⇒ String
Generates CSV string expressing the details of the receipt.
Methods included from Decorator
#initialize, #method_missing, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Panier::Decorators::Decorator
Instance Method Details
#to_csv ⇒ String
Generates CSV string expressing the details of the receipt.
16 17 18 19 20 21 22 23 24 25 26 |
# 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 |