Exception represents an exception rule (e.g. !parliament.uk).
Initializes a new rule from definition
.
The bang ! is removed from the value, as it's common for each wildcard rule.
@param definition [String] the rule as defined in the PSL
# File lib/public_suffix/rule.rb, line 271 def initialize(definition, private: false) super(definition.to_s[1..-1], private: private) end
Decomposes the domain name according to rule properties.
@param [String, to_s] name The domain name to decompose @return [Array<String>] The array with [trd + sld, tld].
# File lib/public_suffix/rule.rb, line 286 def decompose(domain) suffix = parts.join('\.') matches = domain.to_s.match(/^(.*)\.(#{suffix})$/) matches ? matches[1..2] : [nil, nil] end
Gets the length of this rule for comparison, represented by the number of dot-separated parts in the rule.
@return [Integer] The length of the rule.
# File lib/public_suffix/rule.rb, line 309 def length @length ||= parts.length end
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.
@return [Array<String>]
# File lib/public_suffix/rule.rb, line 301 def parts @value.split(DOT)[1..-1] end
Gets the original rule definition.
@return [String] The rule definition.
# File lib/public_suffix/rule.rb, line 278 def rule BANG + value end