Class: CashRegister::NormalItem
- Inherits:
-
Object
- Object
- CashRegister::NormalItem
- Includes:
- Helper
- Defined in:
- lib/cash_register/normal_item.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#deal ⇒ Object
Returns the value of attribute deal.
Instance Method Summary collapse
- #billing ⇒ Object
-
#initialize(deal, count) ⇒ NormalItem
constructor
A new instance of NormalItem.
- #saving ⇒ Object
- #to_s ⇒ Object
Methods included from Helper
Constructor Details
#initialize(deal, count) ⇒ NormalItem
Returns a new instance of NormalItem.
9 10 11 12 |
# File 'lib/cash_register/normal_item.rb', line 9 def initialize(deal, count) @deal = deal @count = count end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
7 8 9 |
# File 'lib/cash_register/normal_item.rb', line 7 def count @count end |
#deal ⇒ Object
Returns the value of attribute deal.
7 8 9 |
# File 'lib/cash_register/normal_item.rb', line 7 def deal @deal end |
Instance Method Details
#billing ⇒ Object
14 15 16 |
# File 'lib/cash_register/normal_item.rb', line 14 def billing @billing ||= deal.price * count end |
#saving ⇒ Object
18 19 20 |
# File 'lib/cash_register/normal_item.rb', line 18 def saving 0 end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/cash_register/normal_item.rb', line 22 def to_s "名称:#{deal.name},数量:#{count}#{deal.unit},单价:#{format_price deal.price}(元),小计:#{format_price billing}(元)" end |