Class: PublicSuffixService::Rule
- Inherits:
-
Object
- Object
- PublicSuffixService::Rule
- Defined in:
- lib/public_suffix_service/rule.rb
Defined Under Namespace
Classes: Base, Exception, Normal, Wildcard
Class Method Summary collapse
-
.factory(name) ⇒ Object
Takes the
name
of the rule, detects the specific rule class and creates a new instance of that class.
Class Method Details
.factory(name) ⇒ Object
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.
name - The String rule definition.
Examples
PublicSuffixService::Rule.factory("ar")
# => #<PublicSuffixService::Rule::Normal>
PublicSuffixService::Rule.factory("*.ar")
# => #<PublicSuffixService::Rule::Wildcard>
PublicSuffixService::Rule.factory("!congresodelalengua3.ar")
# => #<PublicSuffixService::Rule::Exception>
Returns a rule instance, a kind of PublicSuffixService::Rule::Base.
39 40 41 42 43 44 45 46 |
# File 'lib/public_suffix_service/rule.rb', line 39 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 |