Class: Print

Inherits:
Object
  • Object
show all
Defined in:
lib/wunder/print.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checkouts) ⇒ Print

Returns a new instance of Print.



7
8
9
# File 'lib/wunder/print.rb', line 7

def initialize(checkouts)
  @checkouts = checkouts
end

Instance Attribute Details

#checkoutsObject (readonly)

Returns the value of attribute checkouts.



5
6
7
# File 'lib/wunder/print.rb', line 5

def checkouts
  @checkouts
end

Instance Method Details

#tableObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wunder/print.rb', line 11

def table
  rows = []
  headings = ["", "Items In basket", "Applied Promo Rules", "Total Price"]
  checkouts.each_with_index do |checkout, index|
    price = Money.new(checkout.total * 100).format
    items = checkout.basket.items_in_basket
    applied_promotional_rules = checkout.applied_promotional_rules

    rows << ["Test_#{index}", items, applied_promotional_rules, price]
  end
  Terminal::Table.new headings: headings, rows: rows
end