class PublicSuffix::Rule::Base


@abstract
# => [“www.google”, “com”]
rule.decompose(“www.google.com”)
# => [“google”, “com”]
rule.decompose(“google.com”)
rule = PublicSuffix::Rule.factory(“com”)
When you have the right rule, you can use it to tokenize the domain name.
to learn more about rule priority.
See the {Public Suffix Documentation}[http://publicsuffix.org/format/]
Rule order is significant. A name can match more than one rule.
# => false
rule.match?(“google.com”)
# => true
rule.match?(“google.com”)
rule = PublicSuffix::Rule.factory(“com”)
You can use the #match? method.
can be handled by the current rule.
To use a rule, you first need to be sure the name you want to tokenize
the name into tld, sld and trd.
A rule describes the composition of a domain name and explains how to tokenize
## Rule Usage
from the proper rule class.
This method will detect the rule type and create an instance
# => PublicSuffix::Rule::Wildcard
PublicSuffix::Rule.factory(“*.com”)
# => PublicSuffix::Rule::Normal
PublicSuffix::Rule.factory(“com”)
to the PublicSuffix::Rule.factory method.
The best way to create a new rule is passing the rule name
## Rule Creation
>
@value=“google.com”
#<PublicSuffix::Rule::Wildcard:0x1015c14b0
PublicSuffix::Rule.factory(“*.google.com”)
Here’s an example
The normalization process depends on rule tpe.
value - A normalized version of the rule name.
A rule is composed by 4 properties:
## Properties
* {PublicSuffix::Rule::Wildcard}
* {PublicSuffix::Rule::Exception}
* {PublicSuffix::Rule::Normal}
for all the available subclasses.
of this class is to expose a common interface
and you shouldn’t create a direct instance. The only purpose
This is intended to be an Abstract class
in the Public Suffix List.
This represent the base class for a Rule definition
= Abstract rule class

def self.build(content, private: false)

Parameters:
  • private (Boolean) --
  • content (String) -- the content of the rule
def self.build(content, private: false)
  new(value: content, private: private)
end

def ==(other)

Returns:
  • (Boolean) - true if this rule and other are instances of the same class

Parameters:
  • other (PublicSuffix::Rule::*) -- The rule to compare
def ==(other)
  equal?(other) || (self.class == other.class && value == other.value)
end

def decompose(*)

Returns:
  • (Array) -

Parameters:
  • domain (#to_s) -- The domain name to decompose

Other tags:
    Abstract: -
def decompose(*)
  raise NotImplementedError
end

def initialize(value:, length: nil, private: false)

Parameters:
  • private (Boolean) --
  • value (String) --
def initialize(value:, length: nil, private: false)
  @value    = value.to_s
  @length   = length || (@value.count(DOT) + 1)
  @private  = private
end

def match?(name)

Returns:
  • (Boolean) -

Parameters:
  • name (String) -- the domain name to check

Other tags:
    See: https://publicsuffix.org/list/ -
def match?(name)
  # NOTE: it works because of the assumption there are no
  # rules like foo.*.com. If the assumption is incorrect,
  # we need to properly walk the input and skip parts according
  # to wildcard component.
  diff = name.chomp(value)
  diff.empty? || diff.end_with?(DOT)
end

def parts

Other tags:
    Abstract: -
def parts
  raise NotImplementedError
end