Skip to content

Instantly share code, notes, and snippets.

@kitallis
Created December 14, 2010 14:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kitallis/740467 to your computer and use it in GitHub Desktop.
Save kitallis/740467 to your computer and use it in GitHub Desktop.
PratulKalia can do a lot of things.
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 }
}
@ideamonk
Copy link

i can lol

@Gurpartap
Copy link

PratulKalia.should {
    :ensure.this { "kitallis dies in an accident." }
}

@abhinav-upadhyay
Copy link

rofl :-P

@yadurajiv
Copy link

XD

@gsathya
Copy link

gsathya commented Sep 8, 2011

epic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment