dietary_dsl 0.3.1 → 0.4.0
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 -0
- data/lib/dietary_dsl/dsl/plato.rb +4 -0
- data/lib/dietary_dsl/measures/mass.rb +12 -0
- data/lib/dietary_dsl/measures/measure.rb +12 -0
- data/lib/dietary_dsl/measures/volume.rb +26 -14
- 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: f57eda75d75d970e6bdbdccff368bc9898837f0d
|
4
|
+
data.tar.gz: 3b5f5c21628fdcd6bc936bdfced6a88164432ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26296bfdff40667c3bfae669c164c53c2efcd663afb6713fdc7fb7ddd4630b4edea22208070cc5f9543ece75ca9ea6ecbd1f75fd69ba256304e9600e0c73b538
|
7
|
+
data.tar.gz: 54a05961f6a61e9b33334a7b3019b90ddf8432d05aff902eddcf2975a7a3e358aab4ba461857dc75b30f8cde3ce5838d6e22d477b35e8639980d60668c1f3aa2
|
@@ -7,6 +7,8 @@ module DietaryDsl
|
|
7
7
|
class Masa < Measure
|
8
8
|
def initialize(en_gramos)
|
9
9
|
super(en_gramos)
|
10
|
+
@small_postfix = "g"
|
11
|
+
@big_postfix = "kg"
|
10
12
|
end
|
11
13
|
|
12
14
|
# Métodos de clase para instanciarlo
|
@@ -19,6 +21,16 @@ module DietaryDsl
|
|
19
21
|
DietaryDsl::Masa.new(number)
|
20
22
|
end
|
21
23
|
|
24
|
+
# Métodos para heredar
|
25
|
+
|
26
|
+
def big
|
27
|
+
kg
|
28
|
+
end
|
29
|
+
|
30
|
+
def small
|
31
|
+
g
|
32
|
+
end
|
33
|
+
|
22
34
|
# Métodos de conversión
|
23
35
|
|
24
36
|
def g
|
@@ -12,5 +12,17 @@ module DietaryDsl
|
|
12
12
|
def to
|
13
13
|
self
|
14
14
|
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
if @cantidad < 1000
|
18
|
+
"#{small.to_i}#{@small_postfix}"
|
19
|
+
else
|
20
|
+
if big == big.to_i
|
21
|
+
"#{big.to_i}#{@big_postfix}"
|
22
|
+
else
|
23
|
+
"#{big.round(1)}#{@big_postfix}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
@@ -5,53 +5,65 @@ require 'dietary_dsl/measures/measure'
|
|
5
5
|
module DietaryDsl
|
6
6
|
# Esta clase nos permite representar unidades de volumen, como litros o cucharadas.
|
7
7
|
class Volumen < Measure
|
8
|
-
def initialize(
|
9
|
-
super(
|
8
|
+
def initialize(en_ml)
|
9
|
+
super(en_ml)
|
10
10
|
@cantidad = cantidad.to_f
|
11
|
+
@small_postfix = "ml"
|
12
|
+
@big_postfix = "L"
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.l(number)
|
14
|
-
Volumen.new(number)
|
16
|
+
Volumen.new(number * 1000.0)
|
15
17
|
end
|
16
18
|
|
17
19
|
def self.ml(number)
|
18
|
-
Volumen.new(number
|
20
|
+
Volumen.new(number)
|
19
21
|
end
|
20
22
|
|
21
23
|
def self.cm3(number)
|
22
|
-
Volumen.new(number
|
24
|
+
Volumen.new(number)
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.cucharada(number)
|
26
|
-
Volumen.new(
|
28
|
+
Volumen.new(number * 15.0)
|
27
29
|
end
|
28
30
|
|
29
31
|
def self.vaso(number)
|
30
|
-
Volumen.new(number
|
32
|
+
Volumen.new(number * 200)
|
31
33
|
end
|
32
34
|
|
33
35
|
def self.chorrito(number)
|
34
|
-
Volumen.new(number
|
36
|
+
Volumen.new(number * 62.5)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Métodos para heredar
|
40
|
+
|
41
|
+
def big
|
42
|
+
l
|
43
|
+
end
|
44
|
+
|
45
|
+
def small
|
46
|
+
ml
|
35
47
|
end
|
36
48
|
|
37
49
|
def l
|
38
|
-
@cantidad
|
50
|
+
@cantidad / 1000
|
39
51
|
end
|
40
52
|
|
41
53
|
def litros
|
42
|
-
|
54
|
+
l
|
43
55
|
end
|
44
56
|
|
45
57
|
def cm3
|
46
|
-
@cantidad
|
58
|
+
@cantidad
|
47
59
|
end
|
48
60
|
|
49
|
-
def
|
50
|
-
@cantidad
|
61
|
+
def ml
|
62
|
+
@cantidad
|
51
63
|
end
|
52
64
|
|
53
65
|
def cucharadas
|
54
|
-
|
66
|
+
@cantidad / 20
|
55
67
|
end
|
56
68
|
|
57
69
|
def coerce(arg)
|
data/lib/dietary_dsl/version.rb
CHANGED