Class: AlimentoC

Inherits:
Alimento show all
Defined in:
lib/prct06/AlimentoC.rb

Overview

require “valor_calorico.rb”

Instance Attribute Summary collapse

Attributes inherited from Alimento

#datos, #glucidos, #lipidos, #nombre, #proteinas

Instance Method Summary collapse

Methods inherited from Alimento

#<=>, #==, #AIBC, #valor_calorico

Constructor Details

#initialize(nombre, proteinas, glucidos, lipidos, grupo) ⇒ Object

Returns AlimentoC type of the class.

Parameters:

  • nombre,

    proteinas, glucidos, lipidos, grupo [String], [Number], [Number], [Number], [String]



13
14
15
16
# File 'lib/prct06/AlimentoC.rb', line 13

def initialize(nombre, proteinas, glucidos, lipidos, grupo)
  super(nombre, proteinas, glucidos, lipidos)
  @grupo = grupo
end

Instance Attribute Details

#grupoObject

Returns the value of attribute grupo.



9
10
11
# File 'lib/prct06/AlimentoC.rb', line 9

def grupo
  @grupo
end

Instance Method Details

#to_sString

Returns the resulting of join all the information, name, protein, glucids, lipids and group.

Returns:

  • (String)

    the resulting of join all the information, name, protein, glucids, lipids and group



19
20
21
22
23
# File 'lib/prct06/AlimentoC.rb', line 19

def to_s
  s = super.to_s
  s += "\t#{@grupo}"
  s
end