class Nutrition_Info

@author Daniel Darias Sánchez <alu0100783230@ull.edu.es>

Attributes

Calories[R]
Fats[R]
Hidrates[R]
Proteins[R]

Public Class Methods

new(hidrates, proteins, fats, calories) click to toggle source
# 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

Public Instance Methods

check_great_zero(param) click to toggle source

checks if the argument is valid

# File lib/Prct07/Nutrition_Info.rb, line 13
def check_great_zero(param)
  if (param < 0)
    0
  else
    param
  end
end
to_s() click to toggle source

necessary for puts method

# 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