class Recipe
Attributes
ingredients[RW]
instructions[RW]
name[RW]
Public Class Methods
new(name) { |self| ... }
click to toggle source
# File lib/Bibliografia/recipe.rb, line 4 def initialize(name, &block) self.name = name self.ingredients = [] self.instructions = [] if block_given? if block.arity == 1 yield self else instance_eval &block end end end
Public Instance Methods
ingredient(name, options = {})
click to toggle source
# File lib/Bibliografia/recipe.rb, line 30 def ingredient(name, options = {}) ingredient = name ingredient << " (#{options[:amount]})" if options[:amount] ingredients << ingredient end
step(text, options = {})
click to toggle source
# File lib/Bibliografia/recipe.rb, line 37 def step(text, options = {}) instruction = text instruction << " (#{options[:during]})" if options[:during] instructions << instruction end
to_s()
click to toggle source
# File lib/Bibliografia/recipe.rb, line 18 def to_s output = name output << "\n#{'=' * name.size}\n\n" output << "Ingredients: #{ingredients.join(', ')}\n\n" instructions.each_with_index do |instruction, index| output << "#{index + 1}) #{instruction}\n" end output end