Class: PublicSuffixService::Rule::Wildcard

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

Instance Attribute Summary

Attributes inherited from Base

#labels, #name, #type, #value

Instance Method Summary collapse

Methods inherited from Base

#==, #match?

Constructor Details

#initialize(name) ⇒ Wildcard

Returns a new instance of Wildcard.



230
231
232
# File 'lib/public_suffix_service/rule.rb', line 230

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

Instance Method Details

#decompose(domain) ⇒ Object

Decomposes the domain according to rule properties.

domain - The String domain name to parse.

Return an Array with [trd + sld, tld].



251
252
253
254
# File 'lib/public_suffix_service/rule.rb', line 251

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

#lengthObject



242
243
244
# File 'lib/public_suffix_service/rule.rb', line 242

def length
  parts.length + 1 # * counts as 1
end

#partsObject

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

Returns an Array with the domain parts.



238
239
240
# File 'lib/public_suffix_service/rule.rb', line 238

def parts
  @parts ||= @value.split(".")
end