Class: PublicSuffix::Rule::Exception
- Defined in:
- lib/public_suffix/rule.rb
Overview
Exception represents an exception rule (e.g. !parliament.uk).
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#decompose(domain) ⇒ Array<String>
Decomposes the domain name according to rule properties.
-
#initialize(definition, **options) ⇒ Exception
constructor
Initializes a new rule from
definition. -
#length ⇒ Integer
Gets the length of this rule for comparison, represented by the number of dot-separated parts in the rule.
-
#parts ⇒ Array<String>
dot-split rule value and returns all rule parts in the order they appear in the value.
-
#rule ⇒ String
Gets the original rule definition.
Methods inherited from Base
Constructor Details
#initialize(definition, **options) ⇒ Exception
Initializes a new rule from definition.
The bang ! is removed from the value, as it’s common for each wildcard rule.
278 279 280 |
# File 'lib/public_suffix/rule.rb', line 278 def initialize(definition, **) super(definition.to_s[1..-1], **) end |
Instance Method Details
#decompose(domain) ⇒ Array<String>
Decomposes the domain name according to rule properties.
293 294 295 296 297 |
# File 'lib/public_suffix/rule.rb', line 293 def decompose(domain) suffix = parts.join('\.') matches = domain.to_s.match(/^(.*)\.(#{suffix})$/) matches ? matches[1..2] : [nil, nil] end |
#length ⇒ Integer
Gets the length of this rule for comparison, represented by the number of dot-separated parts in the rule.
316 317 318 |
# File 'lib/public_suffix/rule.rb', line 316 def length @length ||= parts.length end |
#parts ⇒ Array<String>
dot-split rule value and returns all rule parts in the order they appear in the value. The leftmost label is not considered a label.
See publicsuffix.org/format/: If the prevailing rule is a exception rule, modify it by removing the leftmost label.
308 309 310 |
# File 'lib/public_suffix/rule.rb', line 308 def parts @value.split(DOT)[1..-1] end |
#rule ⇒ String
Gets the original rule definition.
285 286 287 |
# File 'lib/public_suffix/rule.rb', line 285 def rule BANG + value end |