Skip to content

Commit

Permalink
Merge branch 'desarrollo'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitor Hernández committed Jan 11, 2019
2 parents b2141f6 + 48fa6ba commit 7e15569
Show file tree
Hide file tree
Showing 5 changed files with 604 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

task :default => :spec

task :p12 do
sh 'bundle exec rspec spec/p12_spec.rb'
end
13 changes: 13 additions & 0 deletions lib/gema/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def to_s
output << "#{index+1}) #{alimento}\n"
end

output << "\n Valor energético total del menú: #{total_ve}\n"

output
end

Expand Down Expand Up @@ -88,6 +90,17 @@ def cena(alimento, composicion = {})
end


def total_ve

all = 0.0
all += @desayuno.map { |ali| ali.val_energetico }.reduce(:+)
all += @almuerzo.map { |ali| ali.val_energetico }.reduce(:+)
all += @cena.map { |ali| ali.val_energetico }.reduce(:+)

return all.round(3)

end


end

Expand Down
Loading

0 comments on commit 7e15569

Please sign in to comment.