Class: PublicSuffix::Rule::Normal

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

Overview

Normal represents a standard rule (e.g. com).

Instance Attribute Summary

Attributes inherited from Base

#length, #private, #value

Instance Method Summary collapse

Methods inherited from Base

#==, build, #initialize, #match?

Constructor Details

This class inherits a constructor from PublicSuffix::Rule::Base

Instance Method Details

#decompose(domain) ⇒ Array<String>

Decomposes the domain name according to rule properties.

Parameters:

  • domain (#to_s)

    The domain name to decompose

Returns:

  • (Array<String>)

    The array with [trd + sld, tld].



200
201
202
203
204
# File 'lib/public_suffix/rule.rb', line 200

def decompose(domain)
  suffix = parts.join('\.')
  matches = domain.to_s.match(/^(.*)\.(#{suffix})$/)
  matches ? matches[1..2] : [nil, nil]
end

#partsArray<String>

dot-split rule value and returns all rule parts in the order they appear in the value.

Returns:

  • (Array<String>)


210
211
212
# File 'lib/public_suffix/rule.rb', line 210

def parts
  @value.split(DOT)
end

#ruleString

Gets the original rule definition.

Returns:

  • (String)

    The rule definition.



192
193
194
# File 'lib/public_suffix/rule.rb', line 192

def rule
  value
end