class Menu

Attributes

cal[R]
cvt[R]
menu[R]
percentage[R]
title[R]

Public Class Methods

new(a=[],b=[],c=[],d=[],e=[], &block) click to toggle source

Creates a new diet Menu.

@param a the menu title @param b the menu percentage @param c the menu calories @param d the menu plates @param e the menu cvt @return [Menu] the menu created.

# File lib/menu.rb, line 12
def initialize (a=[],b=[],c=[],d=[],e=[], &block)
    
    @title, @percentage, @cal = a, b, d  
    @menu= c
    @cvt= e
    if(block_given?)
        instance_eval(&block)
    end
end

Public Instance Methods

<=>(anOther) click to toggle source

Menus comparable function.

@return true or false depending of the operator.

# File lib/menu.rb, line 103
def <=>(anOther)
    to_s.length <=> anOther.to_s.length
end
head(op) click to toggle source
# File lib/menu.rb, line 108
def head(op)
  @title = "#{op[:title]}"
  @percentage = "#{op[:percentage]}"
end
menu_to_s() click to toggle source

Returns the menu’s plates to string.

@return the menu’s plates to string.

nutritionfact(op) click to toggle source
# File lib/menu.rb, line 116
def nutritionfact(op)
  @cvt = op[:cvt]
  @cal = op[:cal]
end
plate(op) click to toggle source
# File lib/menu.rb, line 112
def plate(op)
  @menu =  op[:menu]
end
title_to_s() click to toggle source

Returns the menu’s title to string.

@return the menu’s title to stringr.

# File lib/menu.rb, line 24
def title_to_s
    out = @title
    out <<  " ("
    out << @percentage
    out << ")"
    out
end
to_s() click to toggle source

Returns the menu to string.

@return the menu to string.

# File lib/menu.rb, line 70
def to_s
    
    out = @title
    out <<  " ("
    out << @percentage
    out << ")\n"
    
    i=0
    @menu.each do
        out << "- "
        out << "#{@menu[i]}"
        out << "\n"
        i+=1
        
    end
    
    out << "V.C.T.|       "
    out << @cal
    out << "|"
    i=0
    @cvt.each do
        out << "#{@cvt[i]}"
        out << "-"
    i+=1
    end
    out = out.chop
    out
    
end