class Recipe
Attributes
ingredients[RW]
instructions[RW]
name[RW]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/prct11/prueba.rb, line 4 def initialize(name, &block) self.name = name self.ingredients = [] self.instructions = [] instance_eval &block end
Public Instance Methods
amount()
click to toggle source
# File lib/prct11/prueba.rb, line 38 def amount :amount end
during()
click to toggle source
# File lib/prct11/prueba.rb, line 42 def during :for end
ingredient(name, options = {})
click to toggle source
# File lib/prct11/prueba.rb, line 24 def ingredient(name, options = {}) ingredient = name ingredient << " (#{options[:amount]})" if options[:amount] ingredients << ingredient end
step(text, options = {})
click to toggle source
# File lib/prct11/prueba.rb, line 31 def step(text, options = {}) instruction = text instruction << " (#{options[:for]})" if options[:for] instructions << instruction end
to_s()
click to toggle source
# File lib/prct11/prueba.rb, line 12 def to_s output << "EORECIPE #{name} #{'=' * name.size} Ingredients: #{ingredients.join(', ')} #{ out = "" instructions.each_with_index do |instruction, index| out << "#{index + 1}) #{instruction}\n" end out } EORECIPE" end