Guest User

Untitled

a guest
Jul 17th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. class PratulKalia
  2. class << self
  3. def should(&sblk)
  4. self.new.instance_eval(&sblk)
  5. end
  6. end
  7. end
  8.  
  9. class Blabber
  10. def things(arg)
  11. puts "Pratul Kalia should fucken stop blabbering about things like: #{arg.join(", ")}"
  12. end
  13.  
  14. def like(*arg)
  15. arg
  16. end
  17. end
  18.  
  19.  
  20. class Calculate
  21. def initialize
  22. ["expression", "statement", "problem"].map {|m|
  23. class << self
  24. self
  25. end.send(:define_method, m) {|arg|
  26. puts "Pratul Kalia thinks that #{arg}is #{eval arg}"
  27. }
  28. }
  29. end
  30.  
  31. def method_missing(meth, arg = nil, &block)
  32. "#{value(meth)} #{arg}"
  33. end
  34.  
  35. def value(number)
  36. {:one => 1, :two => 2, :three => 3, :four => 4, :five => 5, :six => 6, :seven => 7,
  37. :eight => 8, :nine => 9, :zero => 0}.fetch(number)
  38. end
  39.  
  40. def times(args)
  41. "* #{args}"
  42. end
  43.  
  44. def by(args)
  45. "/ #{args}"
  46. end
  47.  
  48. def from(args)
  49. "- #{args}"
  50. end
  51.  
  52. def with(args)
  53. "+ #{args}"
  54. end
  55.  
  56. end
  57.  
  58. class Symbol
  59. def this(&sblk)
  60. if self == :calculate
  61. Calculate.new.instance_eval(&sblk)
  62. end
  63. if self == :print
  64. puts "Pratul Kalia says #{yield}"
  65. end
  66. end
  67.  
  68. def about(&blk)
  69. if self == :shutup
  70. Blabber.new.instance_eval(&blk)
  71. end
  72. end
  73. end
  74.  
  75. PratulKalia.should {
  76. :print.this { "I AM AWESOME" } & :calculate.this { expression four times three with two } & :shutup.about { things like "FONTS", "OS X", "Sneha" }\
  77. & :calculate.this { statement eight by four with three }
  78. }
Add Comment
Please, Sign In to add comment