Class: PublicSuffix::Rule::Wildcard
- Defined in:
- lib/public_suffix/rule.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#decompose(domain) ⇒ Array<String>
Decomposes the domain according to rule properties.
-
#initialize(name) ⇒ Wildcard
constructor
Initializes a new rule with
name
. -
#length ⇒ Integer
Overwrites the default implementation to cope with the * char.
-
#parts ⇒ Array<String>
dot-split rule value and returns all rule parts in the order they appear in the value.
Methods inherited from Base
Constructor Details
#initialize(name) ⇒ Wildcard
Initializes a new rule with name
.
298 299 300 |
# File 'lib/public_suffix/rule.rb', line 298 def initialize(name) super(name, name.to_s[2..-1]) end |
Instance Method Details
#decompose(domain) ⇒ Array<String>
Decomposes the domain according to rule properties.
326 327 328 329 |
# File 'lib/public_suffix/rule.rb', line 326 def decompose(domain) domain.to_s.chomp(".") =~ /^(.*)\.(.*?\.#{parts.join('\.')})$/ [$1, $2] end |
#length ⇒ Integer
Overwrites the default implementation to cope with the * char.
314 315 316 |
# File 'lib/public_suffix/rule.rb', line 314 def length parts.length + 1 # * counts as 1 end |
#parts ⇒ Array<String>
dot-split rule value and returns all rule parts in the order they appear in the value.
306 307 308 |
# File 'lib/public_suffix/rule.rb', line 306 def parts @parts ||= @value.split(".") end |