Sha256: 3ea0c2adb9c13baa667864ebaa4e59e8204f01ed3300dd0819d91a820cc3422b
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
class DomainCheck::MultiCheck DEFAULT_TLDS = %w(com net org biz info name) def initialize(prefixes: nil, suffixes: nil, tlds: nil) @prefixes = prefixes @suffixes = suffixes @tlds = tlds || DEFAULT_TLDS @tlds.each { |tld| tld.sub!(/^\./, '') } end def check results = [] domains.each do |domain| result = DomainCheck::SingleCheck.new(domain).check yield result if block_given? results << result end results end protected def domains unless @domains @prefixes.uniq! && @prefixes.sort! if @prefixes @suffixes.uniq! && @suffixes.sort! if @suffixes @tlds.sort! && @tlds.uniq! if @prefixes && @suffixes names = [] @prefixes.each do |prefix| @suffixes.each do |suffix| @tlds.each do |tld| names << "#{ prefix }#{ suffix }.#{ tld }" end end end names elsif prefixes names = [] @prefixes.each do |prefix| @tlds.each do |tld| names << "#{ prefix }.#{ tld }" end end elsif suffixes names = [] @suffixes.each do |suffix| @tlds.each do |tld| names << "#{ prefix }#{ suffix }.#{ tld }" end end names else [] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
domain_check-0.0.3 | lib/domain_check/multi_check.rb |
domain_check-0.0.2 | lib/domain_check/multi_check.rb |
domain_check-0.0.1 | lib/domain_check/multi_check.rb |