dietary_dsl 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7daff4360e86c5256697da8874d2355f82a182e
4
- data.tar.gz: f0a650c9f0d59d03c8d4177d45ec42757b3c44d3
3
+ metadata.gz: c966d2b988fb5af0c3316771b2def21df1b52cba
4
+ data.tar.gz: 09f3162643914ef7d09f792626aefd7be33f419a
5
5
  SHA512:
6
- metadata.gz: 16a91d13e5e85393f99ab918e6024404958f12c743ee424a51f7f12aa75d86b62d3f8387953376464ace06f87c3ce76cae3e224a20c907ccd6bf9be8366c3e09
7
- data.tar.gz: 755260a6eee2bf49a3669eaeffcde869dff90cad0b721b7e8941a53b5e88dfe7426b1a3a16b3f0460315dcd0042f7eeda24fcfbf8b25989b05a4dd0d16be8fed
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 Exception => e
29
+ rescue StandardError => e
30
30
  raise "El servidor ha devuelto un error: #{e.message}"
31
31
  end
32
32
 
@@ -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
- if racion.nil?
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
@@ -96,10 +96,10 @@ class Numeric
96
96
  end
97
97
 
98
98
  def rodaja
99
- kg
99
+ DietaryDsl::Masa.rodaja(self)
100
100
  end
101
101
 
102
102
  def rodajas
103
- kg
103
+ rodaja
104
104
  end
105
105
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DietaryDsl
4
- VERSION = '0.5.3'
4
+ VERSION = '0.5.4'
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.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Ramos