2007-12-27 21:18:05 -05:00
|
|
|
SCRIPT_LINES__={}
|
|
|
|
|
2007-12-25 02:04:30 -05:00
|
|
|
class Object
|
2007-12-30 09:20:37 -05:00
|
|
|
@@golf_hash = {}
|
2007-12-25 02:04:30 -05:00
|
|
|
def method_missing m, *a, &b
|
2007-12-30 19:33:40 -05:00
|
|
|
t = @@golf_hash.fetch(k = [m,self.class]) do
|
|
|
|
r = /^#{m.to_s.gsub(/(?<=\w)(?=_)/, '\w*?')}/
|
|
|
|
@@golf_hash[k] = (methods + private_methods).sort.find{|e|r=~e}
|
|
|
|
end
|
2007-12-25 02:04:30 -05:00
|
|
|
t ? __send__(t, *a, &b) : super
|
|
|
|
end
|
2007-12-25 02:42:53 -05:00
|
|
|
|
2007-12-27 20:07:21 -05:00
|
|
|
def self.const_missing c
|
|
|
|
r = /^#{c}/
|
2007-12-27 23:46:56 -05:00
|
|
|
t = constants.sort.find{|e|r=~e} and return const_get(t)
|
|
|
|
raise NameError, "uninitialized constant #{c}", caller(1)
|
2007-12-27 20:07:21 -05:00
|
|
|
end
|
|
|
|
|
2007-12-25 02:42:53 -05:00
|
|
|
def h(a='H', b='w', c='!')
|
|
|
|
puts "#{a}ello, #{b}orld#{c}"
|
|
|
|
end
|
2007-12-27 21:18:05 -05:00
|
|
|
|
|
|
|
def quine(src = $0)
|
2007-12-27 21:39:51 -05:00
|
|
|
SCRIPT_LINES__[src].join
|
2007-12-27 21:18:05 -05:00
|
|
|
end
|
2007-12-28 06:20:59 -05:00
|
|
|
|
|
|
|
alias say puts
|
2007-12-25 02:04:30 -05:00
|
|
|
end
|
2007-12-27 11:47:58 -05:00
|
|
|
|
|
|
|
class Integer
|
2007-12-27 23:59:00 -05:00
|
|
|
alias each times
|
2007-12-27 11:47:58 -05:00
|
|
|
include Enumerable
|
|
|
|
end
|
2007-12-30 09:49:22 -05:00
|
|
|
|
|
|
|
class String
|
|
|
|
alias / split
|
|
|
|
end
|