require 'pathname'

Pathname('/proc/').children.group_by(&:ftype).each do |type, files|
	files.first(10).each_with_index do |file, index|
		lambda do |file, type|
			"%-30s%-10s" % [file, type]
	    end
	    .tap do |printer|
	    	puts printer.call "path", "type" if index.zero?

    		puts printer.call file, "%s (%s)" % [type, files.size]
	    end
	 end
	 
	 (files.size - 10).tap do |remain|
	 	if remain > 0
	 		puts "(another #{remain})\n\n"
	 	else
	 		puts
	 	end
	 end
end