class NewDiet
Attributes
ingesta[R]
name[R]
platos[R]
porcentajes[R]
titulo[R]
vct[R]
Public Class Methods
new(name,&block)
click to toggle source
# File lib/practica6/practica10.rb, line 4 def initialize(name,&block) @name=name @ingesta = "" @platos = [] @porcentajes = [] instance_eval(&block) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/practica6/practica10.rb, line 12 def <=>(other) @porcentajes[0]<=>other.porcentajes[0] end
==(other)
click to toggle source
# File lib/practica6/practica10.rb, line 15 def ==(other) @ingesta==other.ingesta @platos==other.platos @porcentajes==other.porcentajes @vct==other.vct end
plato(options = {})
click to toggle source
# File lib/practica6/practica10.rb, line 31 def plato(options = {}) platos_tmp="" platos_tmp << "- #{options[:descripcion]}, #{options[:porcion]}, #{options[:gramos]} gramos\n" if options[:descripcion] && options[:porcion] && options[:gramos] @platos << platos_tmp end
to_s()
click to toggle source
# File lib/practica6/practica10.rb, line 45 def to_s s="#{@titulo} #{@ingesta}%\n" $i=0 for i in 0..platos.length s+="#{@platos[i]}" $i=$i+1 end s+="VCT #{@porcentajes[0]} | #{porcentajes[1]}" s end