Class: PublicSuffix::Rule
- Inherits:
-
Object
- Object
- PublicSuffix::Rule
- Defined in:
- lib/public_suffix/rule.rb
Overview
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 #factory method.
PublicSuffix::Rule.factory("ar")
# => #<PublicSuffix::Rule::Normal>
Defined Under Namespace
Classes: Base, Exception, Normal, Wildcard
Class Method Summary collapse
-
.factory(name) ⇒ PublicSuffix::Rule::*
Takes the
name
of the rule, detects the specific rule class and creates a new instance of that class.
Class Method Details
.factory(name) ⇒ PublicSuffix::Rule::*
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
.
45 46 47 48 49 50 51 52 |
# 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 |