Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PratulKalia
- class << self
- def should(&sblk)
- self.new.instance_eval(&sblk)
- end
- end
- end
- class Blabber
- def things(arg)
- puts "Pratul Kalia should fucken stop blabbering about things like: #{arg.join(", ")}"
- end
- def like(*arg)
- arg
- end
- end
- class Calculate
- def initialize
- ["expression", "statement", "problem"].map {|m|
- class << self
- self
- end.send(:define_method, m) {|arg|
- puts "Pratul Kalia thinks that #{arg}is #{eval arg}"
- }
- }
- end
- def method_missing(meth, arg = nil, &block)
- "#{value(meth)} #{arg}"
- end
- def value(number)
- {:one => 1, :two => 2, :three => 3, :four => 4, :five => 5, :six => 6, :seven => 7,
- :eight => 8, :nine => 9, :zero => 0}.fetch(number)
- end
- def times(args)
- "* #{args}"
- end
- def by(args)
- "/ #{args}"
- end
- def from(args)
- "- #{args}"
- end
- def with(args)
- "+ #{args}"
- end
- end
- class Symbol
- def this(&sblk)
- if self == :calculate
- Calculate.new.instance_eval(&sblk)
- end
- if self == :print
- puts "Pratul Kalia says #{yield}"
- end
- end
- def about(&blk)
- if self == :shutup
- Blabber.new.instance_eval(&blk)
- end
- end
- end
- PratulKalia.should {
- :print.this { "I AM AWESOME" } & :calculate.this { expression four times three with two } & :shutup.about { things like "FONTS", "OS X", "Sneha" }\
- & :calculate.this { statement eight by four with three }
- }
Add Comment
Please, Sign In to add comment