Class: Harvard_DSL
- Inherits:
-
Object
- Object
- Harvard_DSL
- Defined in:
- lib/alimentos/harvard_dsl.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#platos ⇒ Object
Returns the value of attribute platos.
Instance Method Summary collapse
- #aceite(titulo, options = {}) ⇒ Object
- #cereal(titulo, options = {}) ⇒ Object
- #fruta(titulo, options = {}) ⇒ Object
-
#initialize(name, &block) ⇒ Harvard_DSL
constructor
A new instance of Harvard_DSL.
- #proteina(titulo, options = {}) ⇒ Object
- #to_s ⇒ Object
- #vegetal(titulo, options = {}) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Harvard_DSL
Returns a new instance of Harvard_DSL.
4 5 6 7 8 9 |
# File 'lib/alimentos/harvard_dsl.rb', line 4 def initialize(name, &block) self.name = name self.platos = [] instance_eval &block end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/alimentos/harvard_dsl.rb', line 2 def name @name end |
#platos ⇒ Object
Returns the value of attribute platos.
2 3 4 |
# File 'lib/alimentos/harvard_dsl.rb', line 2 def platos @platos end |
Instance Method Details
#aceite(titulo, options = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/alimentos/harvard_dsl.rb', line 39 def aceite(titulo, = {}) platos << titulo platos << " (#{[:porcion]})" if [:porcion] platos << " (#{[:gramos]})" if [:gramos] platos << "\n" end |
#cereal(titulo, options = {}) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/alimentos/harvard_dsl.rb', line 25 def cereal(titulo, = {}) platos << titulo platos << " (#{[:porcion]})" if [:porcion] platos << " (#{[:gramos]})" if [:gramos] platos << "\n" end |
#fruta(titulo, options = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/alimentos/harvard_dsl.rb', line 18 def fruta(titulo, = {}) platos << titulo platos << " (#{[:porcion]})" if [:porcion] platos << " (#{[:gramos]})" if [:gramos] platos << "\n" end |
#proteina(titulo, options = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/alimentos/harvard_dsl.rb', line 32 def proteina(titulo, = {}) platos << titulo platos << " (#{[:porcion]})" if [:porcion] platos << " (#{[:gramos]})" if [:gramos] platos << "\n" end |
#to_s ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/alimentos/harvard_dsl.rb', line 46 def to_s output = "" output << name output << "\n" for i in 0..name.size-1 do output << "=" end output << "\n" output << "\nComposiciĆ³n nutricional:\n" output << "\n" platos.each_with_index do |plato, index| output << "#{plato}" if index>0 if (index-1) % 3 == 1 output << "\n" end end end output end |
#vegetal(titulo, options = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/alimentos/harvard_dsl.rb', line 11 def vegetal(titulo, = {}) platos << titulo platos << " (#{[:porcion]})" if [:porcion] platos << " (#{[:gramos]})" if [:gramos] platos << "\n" end |