meta_guru.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. class MetaGuru
  2. require "singleton"
  3. include Singleton
  4. def enlighten student
  5. student.extend MetaKoans
  6. koans = student.methods.grep(%r/koan/).sort
  7. attainment = nil
  8. koans.each do |koan|
  9. awakened = student.ponder koan
  10. if awakened
  11. puts "#{ koan } has expanded your awareness"
  12. attainment = koan
  13. else
  14. puts "#{ koan } still requires meditation"
  15. break
  16. end
  17. end
  18. puts(
  19. case attainment
  20. when nil
  21. "mountains are merely mountains"
  22. when 'koan_1', 'koan_2'
  23. "learn the rules so you know how to break them properly"
  24. when 'koan_3', 'koan_4'
  25. "remember that silence is sometimes the best answer"
  26. when 'koan_5', 'koan_6'
  27. "sleep is the best meditation"
  28. when 'koan_7'
  29. "when you lose, don't lose the lesson"
  30. when 'koan_8'
  31. "things are not what they appear to be: nor are they otherwise"
  32. else
  33. "mountains are again merely mountains"
  34. end
  35. )
  36. end
  37. def self::method_missing m, *a, &b
  38. instance.send m, *a, &b
  39. end
  40. end