dietary_dsl 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2981d27c2a7427b6c3a801e5f70146a66e7c2be7
4
- data.tar.gz: c1465601858756a0be0288f05f2b3fd000b8802e
3
+ metadata.gz: a7daff4360e86c5256697da8874d2355f82a182e
4
+ data.tar.gz: f0a650c9f0d59d03c8d4177d45ec42757b3c44d3
5
5
  SHA512:
6
- metadata.gz: 23c5d764ae9b7505f28f03d06eb1218d8cd260514549d3266a462ff5899523d80c7eec1312ce58de34de91a04e697684d6b128951d83ddf6b7565c44f78fd6df
7
- data.tar.gz: 3d7b4d7ac1239ffba00c853de5c45c17f2c1877e2f53b9ca28a115585d505b86d2aa8e41658a89b33c6aa1fabe6fed081cd3e6fc078e24c499beb718a82a2e02
6
+ metadata.gz: 16a91d13e5e85393f99ab918e6024404958f12c743ee424a51f7f12aa75d86b62d3f8387953376464ace06f87c3ce76cae3e224a20c907ccd6bf9be8366c3e09
7
+ data.tar.gz: 755260a6eee2bf49a3669eaeffcde869dff90cad0b721b7e8941a53b5e88dfe7426b1a3a16b3f0460315dcd0042f7eeda24fcfbf8b25989b05a4dd0d16be8fed
@@ -5,14 +5,13 @@ require 'dietary_dsl/dsl/alimento'
5
5
  module DietaryDsl
6
6
  # Clase que representa un menú. Un menú se compone de distintos platos (entrantes, primeros platos, postres...)
7
7
  class Menu
8
- attr_reader :title, :racion
8
+ attr_reader :title
9
9
 
10
10
  include Enumerable
11
11
 
12
12
  def initialize(title, &block)
13
13
  @title = title
14
14
  @platos = []
15
- @racion = nil
16
15
  instance_eval(&block)
17
16
  end
18
17
 
@@ -26,30 +25,23 @@ module DietaryDsl
26
25
 
27
26
  def plato(datos, options = {})
28
27
  return plato_single(datos) if datos.is_a?(Hash)
29
- @platos = @platos.push datos
30
- @racion = options[:racion]
28
+ @platos = @platos.push(plato: datos, racion: options[:racion])
31
29
  end
32
30
 
33
31
  def plato_single(datos)
34
- @platos = @platos.push(DietaryDsl::Plato.new(datos[:food]) { alimento(datos) })
32
+ @platos = @platos.push(plato: DietaryDsl::Plato.new(datos[:food]) { alimento(datos) })
35
33
  end
36
34
 
37
35
  def kcal
38
- kilocalorias = @platos.inject(0) do |sum, plato|
39
- sum + plato.kcal
36
+ @platos.inject(0) do |sum, plato_y_cantidad|
37
+ plato = plato_y_cantidad[:plato]
38
+ racion = plato_y_cantidad[:racion]
39
+ if racion.nil?
40
+ sum + plato.kcal
41
+ else
42
+ sum + ((racion.to.g * plato.kcal) / plato.masa.to.g)
43
+ end
40
44
  end
41
- return racionar(kilocalorias) unless @racion.nil?
42
- kilocalorias
43
- end
44
-
45
- def masa
46
- @platos.inject(0) do |sum, plato|
47
- sum + plato.masa.to.g
48
- end
49
- end
50
-
51
- def racionar(kilocalorias)
52
- (@racion.to.g * kilocalorias) / masa
53
45
  end
54
46
  end
55
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DietaryDsl
4
- VERSION = '0.5.2'
4
+ VERSION = '0.5.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dietary_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Ramos