Class: MenuDSL
- Inherits:
-
Object
- Object
- MenuDSL
- Defined in:
- lib/dieta/menudsl.rb
Instance Attribute Summary collapse
-
#ingestas ⇒ Object
Returns the value of attribute ingestas.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ntitulo ⇒ Object
Returns the value of attribute ntitulo.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcientos ⇒ Object
Returns the value of attribute porcientos.
Instance Method Summary collapse
- #ingesta(options = {}) ⇒ Object
-
#initialize(name, &block) ⇒ MenuDSL
constructor
A new instance of MenuDSL.
- #plato(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulo(text, options = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ MenuDSL
Returns a new instance of MenuDSL.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/dieta/menudsl.rb', line 4 def initialize(name, &block) self.name = name self.ntitulo = [] self.ingestas = [] self.platos = [] self.instructions = [] self.porcientos = [] instance_eval &block end |
Instance Attribute Details
#ingestas ⇒ Object
Returns the value of attribute ingestas.
2 3 4 |
# File 'lib/dieta/menudsl.rb', line 2 def ingestas @ingestas end |
#instructions ⇒ Object
Returns the value of attribute instructions.
2 3 4 |
# File 'lib/dieta/menudsl.rb', line 2 def instructions @instructions end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/dieta/menudsl.rb', line 2 def name @name end |
#ntitulo ⇒ Object
Returns the value of attribute ntitulo.
2 3 4 |
# File 'lib/dieta/menudsl.rb', line 2 def ntitulo @ntitulo end |
#platos ⇒ Object
Returns the value of attribute platos.
2 3 4 |
# File 'lib/dieta/menudsl.rb', line 2 def platos @platos end |
#porcientos ⇒ Object
Returns the value of attribute porcientos.
2 3 4 |
# File 'lib/dieta/menudsl.rb', line 2 def porcientos @porcientos end |
Instance Method Details
#ingesta(options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/dieta/menudsl.rb', line 19 def ingesta( = {}) ingestas << " (#{[:min]})" if [:min] ingestas << " (#{[:max]})" if [:max] end |
#plato(options = {}) ⇒ Object
24 25 26 27 28 |
# File 'lib/dieta/menudsl.rb', line 24 def plato( = {}) platos << " (#{[:descripcion]})" if [:descripcion] platos << " (#{[:porcion]})" if [:porcion] platos << " (#{[:gramos]})" if [:gramos] end |
#porcentajes(options = {}) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/dieta/menudsl.rb', line 30 def porcentajes( = {}) porcientos << " (#{[:vct]})" if [:vct] porcientos << " (#{[:proteinas]})" if [:proteinas] porcientos << " (#{[:grasas]})" if [:grasas] porcientos << " (#{[:hidratos]})" if [:hidratos] end |
#titulo(text, options = {}) ⇒ Object
15 16 17 |
# File 'lib/dieta/menudsl.rb', line 15 def titulo(text, = {}) ntitulo << text end |
#to_s ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dieta/menudsl.rb', line 37 def to_s output = "" output << "#{ntitulo.join(', ')}" output << "\n#{'=' * name.size}\n\n" output << "min: #{ingestas[0]} max: #{ingestas[1]}\n" output << "\nPlatos:\n" platos.each_with_index do |plato, index| output << "#{plato}" if index>0 if (index-1) % 3 == 1 output << "\n" end end end output << "\nPorcientos: vct:#{porcientos[0]}, proteinas:#{porcientos[1]} grasas:#{porcientos[2]} hidratos:#{porcientos[3]}\n" output end |