Parent

Methods

PublicSuffix::Rule

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

There are 3 types of ruleas, 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>

Public Class Methods

factory(name) click to toggle source

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.

@param [String] name The rule definition.

@return [PublicSuffix::Rule::*] A rule instance.

@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>
# File lib/public_suffix/rule.rb, line 45
def self.factory(name)
  klass = case name.to_s[0..0]
    when "*"  then  "wildcard"
    when "!"  then  "exception"
    else            "normal"
  end
  const_get(klass.capitalize).new(name)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.