25 lines
506 B
Plaintext
25 lines
506 B
Plaintext
class Array
|
|
def self.toy(n=10, &block)
|
|
block_given? ? Array.new(n,&block) : Array.new(n) {|i| i+1}
|
|
end
|
|
end
|
|
|
|
class Hash
|
|
def self.toy(n=10)
|
|
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
|
|
end
|
|
end
|
|
|
|
class Object
|
|
def interesting_methods
|
|
case self.class
|
|
when Class
|
|
self.public_methods.sort - Object.public_methods
|
|
when Module
|
|
self.public_methods.sort - Module.public_methods
|
|
else
|
|
self.public_methods.sort - Object.new.public_methods
|
|
end
|
|
end
|
|
end
|