Revisions
-
kitallis created this gist
Dec 14, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ 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 } }