Class: Dieta::Dieta
- Inherits:
-
Object
- Object
- Dieta::Dieta
- Includes:
- Comparable
- Defined in:
- lib/practica8/dieta.rb
Instance Attribute Summary collapse
-
#cabecera ⇒ Object
Returns the value of attribute cabecera.
-
#descrip ⇒ Object
Returns the value of attribute descrip.
-
#vct ⇒ Object
Returns the value of attribute vct.
Instance Method Summary collapse
-
#<=>(otro) ⇒ Object
Comparamos segun la cantidad de calorias del menu.
- #get_footer ⇒ Object
- #get_plato(i) ⇒ Object
- #get_platos ⇒ Object
- #get_porc_gras ⇒ Object
- #get_porc_hdc ⇒ Object
- #get_porc_inges_diaria ⇒ Object
- #get_porc_prot ⇒ Object
- #get_titulo ⇒ Object
- #get_vct ⇒ Object
-
#initialize(a, b, c) ⇒ Dieta
constructor
A new instance of Dieta.
- #to_s ⇒ Object
Constructor Details
#initialize(a, b, c) ⇒ Dieta
Returns a new instance of Dieta
9 10 11 |
# File 'lib/practica8/dieta.rb', line 9 def initialize (a,b,c) @cabecera, @descrip, @vct = a, b, c end |
Instance Attribute Details
#cabecera ⇒ Object
Returns the value of attribute cabecera
5 6 7 |
# File 'lib/practica8/dieta.rb', line 5 def cabecera @cabecera end |
#descrip ⇒ Object
Returns the value of attribute descrip
5 6 7 |
# File 'lib/practica8/dieta.rb', line 5 def descrip @descrip end |
#vct ⇒ Object
Returns the value of attribute vct
5 6 7 |
# File 'lib/practica8/dieta.rb', line 5 def vct @vct end |
Instance Method Details
#<=>(otro) ⇒ Object
Comparamos segun la cantidad de calorias del menu
14 15 16 |
# File 'lib/practica8/dieta.rb', line 14 def <=> (otro) @vct[0] <=> otro.vct[0] end |
#get_footer ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/practica8/dieta.rb', line 92 def out = get_vct out << get_porc_prot out << get_porc_gras out << get_porc_hdc out end |
#get_plato(i) ⇒ Object
44 45 46 47 48 |
# File 'lib/practica8/dieta.rb', line 44 def get_plato(i) out = "#{@descrip[i]}" out end |
#get_platos ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/practica8/dieta.rb', line 50 def get_platos out="" i=0 @descrip.each do out << "- " out << get_plato(i) out << "\n" i+=1 end out end |
#get_porc_gras ⇒ Object
78 79 80 81 82 83 |
# File 'lib/practica8/dieta.rb', line 78 def get_porc_gras out = "#{@vct[2]}" out << "% - " out end |
#get_porc_hdc ⇒ Object
85 86 87 88 89 90 |
# File 'lib/practica8/dieta.rb', line 85 def get_porc_hdc out = "#{@vct[3]}" out << "%" out end |
#get_porc_inges_diaria ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/practica8/dieta.rb', line 34 def get_porc_inges_diaria out = " (" out << "#{@cabecera[1]}" out << " - " out << "#{@cabecera[2]}" out << "%)\n" out end |
#get_porc_prot ⇒ Object
71 72 73 74 75 76 |
# File 'lib/practica8/dieta.rb', line 71 def get_porc_prot out = "#{@vct[1]}" out << "% - " out end |
#get_titulo ⇒ Object
27 28 29 30 31 32 |
# File 'lib/practica8/dieta.rb', line 27 def get_titulo out ="#{@cabecera[0]}" out << get_porc_inges_diaria out end |
#get_vct ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/practica8/dieta.rb', line 63 def get_vct out = "V.C.T. | % " out << "#{@vct[0]}" out << " kcal | " out end |
#to_s ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/practica8/dieta.rb', line 18 def to_s out = get_titulo out << get_platos out << out end |