vendor/bundle/ruby/2.3.0/gems/public_suffix-1.5.3/lib/public_suffix/list.rb
# Returns the most appropriate rule for domain.
#
# From the Public Suffix List documentation:
#
# * If a hostname matches more than one rule in the file,
#   the longest matching rule (the one with the most levels) will be used.
# * An exclamation mark (!) at the start of a rule marks an exception to a previous wildcard rule.
#   An exception rule takes priority over any other matching rule.
#
# == Algorithm description
#
# * Match domain against all rules and take note of the matching ones.
# * If no rules match, the prevailing rule is "*".
# * If more than one rule matches, the prevailing rule is the one which is an exception rule.
# * If there is no matching exception rule, the prevailing rule is the one with the most labels.
# * If the prevailing rule is a exception rule, modify it by removing the leftmost label.
# * The public suffix is the set of labels from the domain
#   which directly match the labels of the prevailing rule (joined by dots).
# * The registered domain is the public suffix plus one additional label.
#
# @param  [String, #to_s] domain The domain name.
#
# @return [PublicSuffix::Rule::*, nil]
Returns the most appropriate rule for domain.
From the Public Suffix List documentation.

If a hostname matches more than one rule in the file,
the longest matching rule (the one with the most levels) will be used.
An exclamation mark (!) at the start of a rule marks an exception to a previous wildcard rule.
An exception rule takes priority over any other matching rule.

Algorithm description

Match domain against all rules and take note of the matching ones.
If no rules match, the prevailing rule is "*".
If more than one rule matches, the prevailing rule is the one which is an exception rule.
If there is no matching exception rule, the prevailing rule is the one with the most labels.
If the prevailing rule is a exception rule, modify it by removing the leftmost label.
The public suffix is the set of labels from the domain
which directly match the labels of the prevailing rule (joined by dots).
The registered domain is the public suffix plus one additional label.
Returns the most appropriate rule for domain . From the Public Suffix List documentation . If a hostname matches more than one rule in the file the longest matching rule ( the one with the most levels ) will be used . An exclamation mark ( ! ) at the start of a rule marks an exception to a previous wildcard rule . An exception rule takes priority over any other matching rule . Algorithm description Match domain against all rules and take note of the matching ones . If no rules match the prevailing rule is " * " . If more than one rule matches the prevailing rule is the one which is an exception rule . If there is no matching exception rule the prevailing rule is the one with the most labels . If the prevailing rule is a exception rule modify it by removing the leftmost label . The public suffix is the set of labels from the domain which directly match the labels of the prevailing rule ( joined by dots ) . The registered domain is the public suffix plus one additional label .
def find(domain)
      rules = select(domain)
      rules.detect { |r|   r.type == :exception } ||
      rules.inject { |t,r| t.length > r.length ? t : r }
    end
def find ( domain ) rules = select ( domain ) rules . detect { | r | r . type == :exception } || rules . inject { | t , r | t . length > r . length ? t : r } end
Returns the most appropriate rule for domain.
Returns the most appropriate rule for domain .
None
PublicSuffix::Rule::*, nil
domain
<not_specific>
<not_specific>
domain The domain name.
domain The domain name .