module PublicSuffix::Rule

Overview

A Rule is a special object which holds a single definition of the Public Suffix List.

There are 3 types of rules, each one represented by a specific subclass within the +PublicSuffix::Rule+ namespace.

To create a new Rule, use the {PublicSuffix::Rule#factory} method.

PublicSuffix::Rule.factory("ar")

=> #PublicSuffix::Rule::Normal

Defined in:

public_suffix/rule.cr

Constant Summary

DEFAULT = Wildcard.new("", 2)

Class Method Summary

Class Method Detail

def self.default #

The default rule to use if no rule match.

The default rule is "*". From https://publicsuffix.org/list/:

If no rules match, the prevailing rule is "*".

@return [PublicSuffix::Rule::Wildcard] The default rule.


[View source]
def self.factory(content : String, _private = false) #

Takes the +name+ of the rule, detects the specific rule class and creates a new instance of that class. The +name+ becomes the rule +value+.

@example Creates a Normal rule PublicSuffix::Rule.factory("ar")

=> #PublicSuffix::Rule::Normal

@example Creates a Wildcard rule PublicSuffix::Rule.factory("*.ar")

=> #PublicSuffix::Rule::Wildcard

@example Creates an Exception rule PublicSuffix::Rule.factory("!congresodelalengua3.ar")

=> #PublicSuffix::Rule::Exception

@param [String] content The rule content. @return [PublicSuffix::Rule::*] A rule instance.


[View source]