Class: BasketItem
- Inherits:
-
Object
- Object
- BasketItem
- Defined in:
- lib/wunder/basket_item.rb
Instance Attribute Summary collapse
-
#product ⇒ Object
Returns the value of attribute product.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
Instance Method Summary collapse
- #decrement_item_quantity ⇒ Object
- #increment_item_quantity ⇒ Object
-
#initialize(product) ⇒ BasketItem
constructor
A new instance of BasketItem.
Constructor Details
#initialize(product) ⇒ BasketItem
Returns a new instance of BasketItem.
4 5 6 7 |
# File 'lib/wunder/basket_item.rb', line 4 def initialize(product) @product = product @quantity = 1 end |
Instance Attribute Details
#product ⇒ Object
Returns the value of attribute product.
2 3 4 |
# File 'lib/wunder/basket_item.rb', line 2 def product @product end |
#quantity ⇒ Object
Returns the value of attribute quantity.
2 3 4 |
# File 'lib/wunder/basket_item.rb', line 2 def quantity @quantity end |
Instance Method Details
#decrement_item_quantity ⇒ Object
13 14 15 |
# File 'lib/wunder/basket_item.rb', line 13 def decrement_item_quantity @quantity -= 1 end |
#increment_item_quantity ⇒ Object
9 10 11 |
# File 'lib/wunder/basket_item.rb', line 9 def increment_item_quantity @quantity += 1 end |