class PublicSuffixList

typed: true

typed: strict

Constants

VERSION

Attributes

cache_file[R]
config[R]

Public Class Methods

config() click to toggle source
# File lib/public_suffix_list.rb, line 12
def self.config
  @@config ||= Config.new
end
configure() { |config| ... } click to toggle source
# File lib/public_suffix_list.rb, line 16
def self.configure(&block)
  yield config
end
new(options = {}) click to toggle source
# File lib/public_suffix_list.rb, line 40
def initialize(options = {})
  @config = self.class.config.dup
  options.each { |k, v| @config.send("#{k}=", v) }
  if @config.cache_dir
    @cache_file = CacheFile.new(@config)
  end
  if @cache_file and @cache_file.exist?
    uncache or (fetch and cache)
  elsif @cache_file
    fetch and cache
  else
    fetch
  end
end

Public Instance Methods

cdn(domain) click to toggle source
# File lib/public_suffix_list.rb, line 73
def cdn(domain)
  domain = domain.split(".")
  result = best(match(domain, rules, true))
  return "" if result.empty?
  gimme!(domain, result.size + 1).join(".")
end
rules() click to toggle source
# File lib/public_suffix_list.rb, line 55
def rules
  @rules
end
split(domain) click to toggle source
# File lib/public_suffix_list.rb, line 59
def split(domain)
  domain = domain.split(".")
  result = best(match(domain, rules, true))
  return ["", "", ""] if result.empty?
  [gimme!(domain, result.size), gimme!(domain), domain].reverse.map { |d| d.join(".") }
end
tld(domain) click to toggle source
# File lib/public_suffix_list.rb, line 66
def tld(domain)
  domain = domain.split(".")
  result = best(match(domain, rules, true))
  return "" if result.empty?
  gimme!(domain, result.size).join(".")
end