Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 19 lines (17 sloc) 0.474 kB
class WideFinder
def initialize(filename, &url_finder)
url_histogram = Hash.new(0)
File.open(filename, "r") do |handle|
while line = handle.gets
url = url_finder.call(line)
url_histogram[url] += 1 if url
end
end
@results = url_histogram.sort { |a, b| a[1] <=> b[1] }.reverse
end
def results(how_many)
@results[0,how_many].inject([]) do |results, result|
results << "#{result[1]}: #{result[0]}"
end
end
end
Jump to Line
Something went wrong with that request. Please try again.