Class: Nutrition_Info
- Inherits:
-
Object
- Object
- Nutrition_Info
- Defined in:
- lib/Prct07/Nutrition_Info.rb
Overview
Instance Attribute Summary collapse
-
#Calories ⇒ Object
readonly
Returns the value of attribute Calories.
-
#Fats ⇒ Object
readonly
Returns the value of attribute Fats.
-
#Hidrates ⇒ Object
readonly
Returns the value of attribute Hidrates.
-
#Proteins ⇒ Object
readonly
Returns the value of attribute Proteins.
Instance Method Summary collapse
-
#check_great_zero(param) ⇒ Object
checks if the argument is valid.
-
#initialize(hidrates, proteins, fats, calories) ⇒ Nutrition_Info
constructor
A new instance of Nutrition_Info.
-
#to_s ⇒ Object
necessary for puts method.
Constructor Details
#initialize(hidrates, proteins, fats, calories) ⇒ Nutrition_Info
Returns a new instance of Nutrition_Info.
5 6 7 8 9 10 |
# File 'lib/Prct07/Nutrition_Info.rb', line 5 def initialize(hidrates, proteins, fats, calories) @Hidrates = check_great_zero hidrates @Proteins = check_great_zero proteins @Fats = check_great_zero fats @Calories = check_great_zero calories end |
Instance Attribute Details
#Calories ⇒ Object (readonly)
Returns the value of attribute Calories.
3 4 5 |
# File 'lib/Prct07/Nutrition_Info.rb', line 3 def Calories @Calories end |
#Fats ⇒ Object (readonly)
Returns the value of attribute Fats.
3 4 5 |
# File 'lib/Prct07/Nutrition_Info.rb', line 3 def Fats @Fats end |
#Hidrates ⇒ Object (readonly)
Returns the value of attribute Hidrates.
3 4 5 |
# File 'lib/Prct07/Nutrition_Info.rb', line 3 def Hidrates @Hidrates end |
#Proteins ⇒ Object (readonly)
Returns the value of attribute Proteins.
3 4 5 |
# File 'lib/Prct07/Nutrition_Info.rb', line 3 def Proteins @Proteins end |
Instance Method Details
#check_great_zero(param) ⇒ Object
checks if the argument is valid
13 14 15 16 17 18 19 |
# File 'lib/Prct07/Nutrition_Info.rb', line 13 def check_great_zero(param) if (param < 0) 0 else param end end |
#to_s ⇒ Object
necessary for puts method
22 23 24 |
# File 'lib/Prct07/Nutrition_Info.rb', line 22 def to_s "hidrates: " + @Hidrates.to_s + ", proteins: " + @Proteins.to_s + ", fats: " + @Fats.to_s + ", kilocalories: " + @Calories.to_s end |