From 75b72701778904c5f71e9f775552ba3b8386120d Mon Sep 17 00:00:00 2001 From: Kensuke Kaneko Date: Thu, 21 Jan 2010 00:38:05 +0900 Subject: [PATCH] =?UTF-8?q?CartItem=20=E3=82=AF=E3=83=A9=E3=82=B9=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- depot/app/models/cart_item.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 depot/app/models/cart_item.rb diff --git a/depot/app/models/cart_item.rb b/depot/app/models/cart_item.rb new file mode 100644 index 0000000..8fe0f04 --- /dev/null +++ b/depot/app/models/cart_item.rb @@ -0,0 +1,20 @@ +class CartItem + attr_reader :product, :quantity + + def initialize (product) + @product = product + @quantity = 1 + end + + def increment_quantity + @quantity += 1 + end + + def title + @product.title + end + + def price + @product.price * @quantity + end +end