10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/calc_calorie/command.rb', line 10
def calc(weight, fat_percent)
weight = weight.to_i
fat_percent = fat_percent.to_i
puts " Weight: #{weight}kg"
puts "Fat Percentage: #{fat_percent}%"
lbm = weight * (100 - fat_percent) / 100
puts "Lean Body Mass: #{lbm}kg"
puts "----------------"
if options[:loss]
kcal = lbm * 35
protein = kcal * 0.35 / 4
fat = kcal * 0.1 / 9
carbohydrates = kcal * 0.55 / 4
elsif options[:gain]
kcal = lbm * 45
protein = kcal * 0.3 / 4
fat = kcal * 0.15 / 9
carbohydrates = kcal * 0.55 / 4
else
kcal = lbm * 40
protein = kcal * 0.3 / 4
fat = kcal * 0.15 / 9
carbohydrates = kcal * 0.55 / 4
end
puts "Today's recommend calorie and PFC is"
puts "kcal: #{kcal}kcal"
puts " P: #{protein.round(1)}g"
puts " F: #{fat.round(1)}g"
puts " C: #{carbohydrates.round(1)}g"
puts "Positive thinking can be contagious. Being surrounded by winners helps you develop into a winner.\n―Arnold Schwarzenegger"
end
|