Class: PublicSuffix::Rule::Exception

Inherits:
Base
  • Object
show all
Defined in:
lib/public_suffix/rule.rb

Instance Attribute Summary

Attributes inherited from Base

#labels, #name, #type, #value

Instance Method Summary collapse

Methods inherited from Base

#==, #allow?, #length, #match?

Constructor Details

#initialize(name) ⇒ Exception

Initializes a new rule with name.

Parameters:

  • name (String)

    The name of this rule.



339
340
341
# File 'lib/public_suffix/rule.rb', line 339

def initialize(name)
  super(name, name.to_s[1..-1])
end

Instance Method Details

#decompose(domain) ⇒ Array<String>

Decomposes the domain according to rule properties.

Parameters:

  • domain (String, #to_s)

    The domain name to decompose.

Returns:

  • (Array<String>)

    The array with [trd + sld, tld].



364
365
366
367
# File 'lib/public_suffix/rule.rb', line 364

def decompose(domain)
  domain.to_s.chomp(".") =~ /^(.*)\.(#{parts.join('\.')})$/
  [$1, $2]
end

#partsArray<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.

Returns:

  • (Array<String>)


352
353
354
# File 'lib/public_suffix/rule.rb', line 352

def parts
  @parts ||= @value.split(".")[1..-1]
end