class Dietadsl
Attributes
atributo[RW]
ingesta_diaria[RW]
instructions[RW]
platos[RW]
porcent[RW]
title[RW]
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/dietas/dsl.rb, line 3 def initialize(&block) self.title = "" self.ingesta_diaria= [] self.porcent= [] self.platos = [] self.instructions = [] self.atributo= "" if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end
Public Instance Methods
grupo(text)
click to toggle source
# File lib/dietas/dsl.rb, line 41 def grupo (text) grupo = text atributo << grupo end
ingesta(options = {})
click to toggle source
# File lib/dietas/dsl.rb, line 46 def ingesta (options = {}) ingesta = " (" ingesta << "#{options[:min]} " if options[:min] ingesta << "- #{options[:max]}" if options[:max] ingesta << "%)" ingesta_diaria << ingesta end
plato(options = {})
click to toggle source
# File lib/dietas/dsl.rb, line 54 def plato(options = {}) plato = "" plato << "- #{options[:descripcion]}," if options[:descripcion] plato << " #{options[:porcion]}," if options[:porcion] plato << " #{options[:gramos]} g" if options[:gramos] plato << " #{options[:mlitros]} ml" if options[:mlitros] plato << "\n" platos << plato end
porcentajes(options = {})
click to toggle source
# File lib/dietas/dsl.rb, line 64 def porcentajes(options = {}) porcentajes = "" porcentajes << "V.C.T | % #{options[:vct]} kcal | " if options[:vct] porcentajes << "#{options[:proteinas]}% - " if options[:proteinas] porcentajes << "#{options[:grasas]}% - " if options[:grasas] porcentajes << "#{options[:hidratos]}%" if options[:hidratos] porcent << porcentajes end
titulo(text)
click to toggle source
# File lib/dietas/dsl.rb, line 36 def titulo (text) titulo = text title << titulo end
to_s()
click to toggle source
# File lib/dietas/dsl.rb, line 20 def to_s if atributo != "" output = atributo + "\n" else output=atributo end output << title output << " #{ingesta_diaria.join()}" #output << "\n#{'=' * titulo.size}\n\n" output << "\n#{platos.join()}" output << "#{porcent.join()}" output end