dietary_dsl 0.5.3 → 0.5.4
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 +4 -4
- data/lib/dietary_dsl/bedca_api/food/orm.rb +1 -1
- data/lib/dietary_dsl/dsl/menu.rb +9 -5
- data/lib/dietary_dsl/measures/mass.rb +2 -2
- data/lib/dietary_dsl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c966d2b988fb5af0c3316771b2def21df1b52cba
|
4
|
+
data.tar.gz: 09f3162643914ef7d09f792626aefd7be33f419a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d28306773b9874849ffb31119985914ed756bf753be6b2e29445010c4bde561a2d30292f8ca567b5eff534bbcfa85371d1dfcdf95828f734b52d4090bd44b790
|
7
|
+
data.tar.gz: 82896bcb6b2b73b8bf2bd81ba33552cd0040576d3a23afeee3efd1b2f97ce837d7acace5ed5e433ccda89a0ffdbea4f45881cd78be34aad68fb042928022de16
|
@@ -26,7 +26,7 @@ module DietaryDsl
|
|
26
26
|
response = @http.request_post URL, XML_HEADER + xml, 'Content-Type' => 'text/xml'
|
27
27
|
body = response.read_body
|
28
28
|
return Hash.from_xml body
|
29
|
-
rescue
|
29
|
+
rescue StandardError => e
|
30
30
|
raise "El servidor ha devuelto un error: #{e.message}"
|
31
31
|
end
|
32
32
|
|
data/lib/dietary_dsl/dsl/menu.rb
CHANGED
@@ -32,15 +32,19 @@ module DietaryDsl
|
|
32
32
|
@platos = @platos.push(plato: DietaryDsl::Plato.new(datos[:food]) { alimento(datos) })
|
33
33
|
end
|
34
34
|
|
35
|
+
def racionar(plato, racion)
|
36
|
+
if racion.nil?
|
37
|
+
plato.kcal
|
38
|
+
else
|
39
|
+
((racion.to.g * plato.kcal) / plato.masa.to.g)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
35
43
|
def kcal
|
36
44
|
@platos.inject(0) do |sum, plato_y_cantidad|
|
37
45
|
plato = plato_y_cantidad[:plato]
|
38
46
|
racion = plato_y_cantidad[:racion]
|
39
|
-
|
40
|
-
sum + plato.kcal
|
41
|
-
else
|
42
|
-
sum + ((racion.to.g * plato.kcal) / plato.masa.to.g)
|
43
|
-
end
|
47
|
+
sum + racionar(plato, racion)
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
data/lib/dietary_dsl/version.rb
CHANGED