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 # Ask for Apartment tenant if defined?(Rails::Console) && defined?(Apartment) available_tenants = Apartment.tenant_names.sort default_tenant = available_tenants.first puts "Available tenants: #{available_tenants.join(',')}" print "Select tenant (#{default_tenant}): " tenant = gets.strip Apartment::Tenant.switch!(available_tenants.include?(tenant) ? tenant : default_tenant) end