The setup steps expect following tools installed on the system.
- Github
- Ruby "3.0.0"
- Rails "7.0.8.1"
git clone git@github.com:eprusakov/cash_register.gitbundle installYou can start the rails console using the command given below.
bundle exec rails cAnd now you can use application inside the rails console
pricing_rules = [Rules::GreenTeaDiscount.new, Rules::StrawberryDiscount.new, Rules::CoffeeDiscount.new]- Rule makes each 2nd green tea free to buy
Rules::GreenTeaDiscount
- Rule makes each strawberry to cost 4.50 if there are 3 or more strawberiies in a cart
Rules::StrawberryDiscount
- Rule drops all coffee prices to 2/3 from the initial cost if there 3 or more coffees in a cart
Rules::CoffeeDiscount
green_tea = Product.new(code: "GT1", name: "Green Tea", price: 3.11)- Green tea
Product.new(code: "GT1", name: "Green Tea", price: 3.11)
- Strawberry
Product.new(code: "SB1", name: "Strawberry", price: 5.00)
- Coffee
Product.new(code: "CF1", name: "Coffee", price: 11.23)
checkout = Checkout.new(pricing_rules)checkout.scan(green_tea)
checkout.scan(*smth_other*)checkout.cartcheckout.total