Class: PlatoDSL
- Inherits:
-
Object
- Object
- PlatoDSL
- Defined in:
- lib/FoodImpact/menu.rb
Instance Method Summary collapse
- #alimento(description = {}) ⇒ Object
-
#initialize(&block) ⇒ PlatoDSL
constructor
A new instance of PlatoDSL.
- #nombre(name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(&block) ⇒ PlatoDSL
Returns a new instance of PlatoDSL.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/FoodImpact/menu.rb', line 2 def initialize(&block) @name = "" @food = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Method Details
#alimento(description = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/FoodImpact/menu.rb', line 18 def alimento(description = {}) new_food = "" new_food += description[:descripcion].to_s new_food += " " new_food += description[:gramos].to_s new_food += " " new_food += description[:proteinas].to_s new_food += " " new_food += description[:lipidos].to_s new_food += " " new_food += description[:carbohidratos].to_s new_food += " " new_food += description[:gei].to_s new_food += " " new_food += description[:terreno].to_s @food << new_food end |
#nombre(name) ⇒ Object
14 15 16 |
# File 'lib/FoodImpact/menu.rb', line 14 def nombre(name) @name = name end |
#to_s ⇒ Object
36 37 38 39 40 |
# File 'lib/FoodImpact/menu.rb', line 36 def to_s out = @name + ", " @food.each { |x| out << "#{x}, "} out end |