Class: PublicSuffixService::Rule::Wildcard
- Defined in:
- lib/public_suffix_service/rule.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#decompose(domain) ⇒ Object
Decomposes the domain according to rule properties.
-
#initialize(name) ⇒ Wildcard
constructor
A new instance of Wildcard.
- #length ⇒ Object
-
#parts ⇒ Object
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
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 |
#length ⇒ Object
242 243 244 |
# File 'lib/public_suffix_service/rule.rb', line 242 def length parts.length + 1 # * counts as 1 end |
#parts ⇒ Object
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 |