Sha256: d9069394940692773fbc2af97422ba1813d49c186cbbe5ba5d389b2353b00db0
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'public_suffix' require 'toml' require 'naughty_or_nice' require_relative 'fortune-finder/record' class FortuneFinder include NaughtyOrNice YEAR = 2015 class << self alias_method :ranked?, :valid? def domains_path @domains_path ||= File.expand_path "./data/#{YEAR}", File.dirname(__FILE__) end def lookup(domain) FortuneFinder.new(domain).lookup end def all @all ||= Dir["#{domains_path}/*.toml"].map { |d| lookup File.basename(d, ".toml") }.sort_by { |d| d.rank } end end def valid? !!record end alias_method :ranked?, :valid? alias_method :fortune1000?, :valid? def fortune50? ranked? && record.rank <= 50 end def fortune100? ranked? && record.rank <= 100 end def fortune500? ranked? && record.rank <= 500 end # Look up a domain name to see if it's the Fortune 2000 list. # # Returns a hash with the ranking and company name if one is found e.g. # #=> {:rank => 1, :name => 'GitHub'} # returns nil if nothing is found. def record @record ||= begin record = FortuneFinder::Record.new(domain) record if record.exists? end end alias_method :lookup, :record end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fortune-finder-0.1.3 | lib/fortune-finder.rb |