Guest User

Page 458 of The Well-grounded Rubyist

a guest
Oct 15th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.31 KB | None | 0 0
  1. class Cookbook
  2.   attr_accessor :title, :author
  3.   def initialize
  4.     @recipes = []
  5.   end
  6.   def method_missing (m,*args,&block)
  7.     @recipes.send(m,*args,&block)
  8.   end
  9. end
  10.  
  11. cb = Cookbook.new
  12. cb << recipe_for_cake
  13. cb << recipe_for_chicken
  14. beef_dishes = cb.select {|recipe| recipe.main_ingredient == "beef" }
Advertisement
Add Comment
Please, Sign In to add comment