mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
18ef0fef15
returns an array of lines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
31 lines
517 B
Ruby
31 lines
517 B
Ruby
SCRIPT_LINES__={}
|
|
|
|
class Object
|
|
def method_missing m, *a, &b
|
|
r = /^#{m}/
|
|
t = (methods + private_methods).sort.find{|e|r=~e}
|
|
t ? __send__(t, *a, &b) : super
|
|
end
|
|
|
|
def self.const_missing c
|
|
r = /^#{c}/
|
|
t = constants.sort.find{|e|r=~e}
|
|
t ? const_get(t) : superclass.const_get(c)
|
|
end
|
|
|
|
def h(a='H', b='w', c='!')
|
|
puts "#{a}ello, #{b}orld#{c}"
|
|
end
|
|
|
|
def quine(src = $0)
|
|
SCRIPT_LINES__[src].join
|
|
end
|
|
end
|
|
|
|
class Integer
|
|
def each(&b)
|
|
times &b
|
|
end
|
|
|
|
include Enumerable
|
|
end
|