Class: Plate
- Inherits:
-
Object
- Object
- Plate
- Defined in:
- lib/Prct07/Plate.rb
Overview
Instance Attribute Summary collapse
-
#Extra ⇒ Object
readonly
Returns the value of attribute Extra.
-
#Name ⇒ Object
readonly
Returns the value of attribute Name.
-
#NutritionalInfo ⇒ Object
readonly
Returns the value of attribute NutritionalInfo.
-
#Quantity ⇒ Object
readonly
Returns the value of attribute Quantity.
Instance Method Summary collapse
-
#check_quantity(quantity) ⇒ Object
checks if the argument is valid.
-
#initialize(name, extra, quantity, nutr_info) ⇒ Plate
constructor
A new instance of Plate.
-
#to_s ⇒ Object
necessary for puts method.
Constructor Details
#initialize(name, extra, quantity, nutr_info) ⇒ Plate
Returns a new instance of Plate.
5 6 7 8 9 10 |
# File 'lib/Prct07/Plate.rb', line 5 def initialize(name, extra, quantity, nutr_info) @Name = name @Extra = extra @Quantity = check_quantity quantity @NutritionalInfo = nutr_info end |
Instance Attribute Details
#Extra ⇒ Object (readonly)
Returns the value of attribute Extra.
3 4 5 |
# File 'lib/Prct07/Plate.rb', line 3 def Extra @Extra end |
#Name ⇒ Object (readonly)
Returns the value of attribute Name.
3 4 5 |
# File 'lib/Prct07/Plate.rb', line 3 def Name @Name end |
#NutritionalInfo ⇒ Object (readonly)
Returns the value of attribute NutritionalInfo.
3 4 5 |
# File 'lib/Prct07/Plate.rb', line 3 def NutritionalInfo @NutritionalInfo end |
#Quantity ⇒ Object (readonly)
Returns the value of attribute Quantity.
3 4 5 |
# File 'lib/Prct07/Plate.rb', line 3 def Quantity @Quantity end |
Instance Method Details
#check_quantity(quantity) ⇒ Object
checks if the argument is valid
13 14 15 16 17 18 19 |
# File 'lib/Prct07/Plate.rb', line 13 def check_quantity(quantity) if (quantity > 0) quantity else 1 end end |
#to_s ⇒ Object
necessary for puts method
22 23 24 |
# File 'lib/Prct07/Plate.rb', line 22 def to_s @Name + ", " + @Extra + ", " + @Quantity.to_s + " g" end |