Class: Menu
- Inherits:
-
Object
- Object
- Menu
- Defined in:
- lib/nutritag/menu.rb
Instance Attribute Summary collapse
-
#almuerzo(options = {}) ⇒ Object
Returns the value of attribute almuerzo.
-
#cena(options = {}) ⇒ Object
Returns the value of attribute cena.
-
#comp ⇒ Object
Returns the value of attribute comp.
-
#day ⇒ Object
Returns the value of attribute day.
-
#desayuno(options = {}) ⇒ Object
Returns the value of attribute desayuno.
-
#ingesta(options = {}) ⇒ Object
Returns the value of attribute ingesta.
-
#title(name) ⇒ Object
Returns the value of attribute title.
-
#v_energetic ⇒ Object
Returns the value of attribute v_energetic.
Instance Method Summary collapse
-
#initialize(day, comp, &block) ⇒ Menu
constructor
A new instance of Menu.
- #to_s ⇒ Object
Constructor Details
#initialize(day, comp, &block) ⇒ Menu
Returns a new instance of Menu.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nutritag/menu.rb', line 5 def initialize(day, comp, &block) @day=day @comp=comp @title @ingesta=[] @desayuno=[] @almuerzo=[] @cena=[] @v_energetic=0 @ve_total=0 @aux=[] @nut= [" ", "Cantidad", "Gramos", "Grasas", "Hidratos", "Proteínas", "Fibra", "Sal", "V. Energético"] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#almuerzo(options = {}) ⇒ Object
Returns the value of attribute almuerzo.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def almuerzo @almuerzo end |
#cena(options = {}) ⇒ Object
Returns the value of attribute cena.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def cena @cena end |
#comp ⇒ Object
Returns the value of attribute comp.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def comp @comp end |
#day ⇒ Object
Returns the value of attribute day.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def day @day end |
#desayuno(options = {}) ⇒ Object
Returns the value of attribute desayuno.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def desayuno @desayuno end |
#ingesta(options = {}) ⇒ Object
Returns the value of attribute ingesta.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def ingesta @ingesta end |
#title(name) ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def title @title end |
#v_energetic ⇒ Object
Returns the value of attribute v_energetic.
3 4 5 |
# File 'lib/nutritag/menu.rb', line 3 def v_energetic @v_energetic end |
Instance Method Details
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/nutritag/menu.rb', line 28 def to_s puts "\n" output = @day.rjust(20) output << "#{' '*40} #{@comp}" output << "\n#{'='*155}" output << "\n#{@title}\n" @nut.each do |i| if( @aux.include?(i) == false) @aux.push(i) end output << "#{i.ljust(17)}" end @aux.clear output << "\n\nDesayuno" @desayuno.each do |i| if( @aux.include?(i) == false) @aux.push(i) end output << "#{i.ljust(17)}" end @aux.clear output << "\n\nAlmuerzo" @almuerzo.each do |i| if( @aux.include?(i) == false) @aux.push(i) end output << "#{i.ljust(17)}" end @aux.clear output << "\n\nCena" @cena.each do |i| if( @aux.include?(i) == false) @aux.push(i) end output << "#{i.ljust(17)}" end output << "\n\n#{'-'*155}" output << "\nIngesta -> #{@ingesta.join(' ')}\n" output << "\nVALOR ENERGÉTICO TOTAL: #{@ve_total.round(2)} kcal" output end |