lib/public_suffix/rule.rb in public_suffix-4.0.6 vs lib/public_suffix/rule.rb in public_suffix-4.0.7
- old
+ new
@@ -2,11 +2,11 @@
# = Public Suffix
#
# Domain name parser based on the Public Suffix List.
#
-# Copyright (c) 2009-2020 Simone Carletti <weppos@weppos.net>
+# Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
module PublicSuffix
# A Rule is a special object which holds a single definition
# of the Public Suffix List.
@@ -129,14 +129,13 @@
@private = private
end
# Checks whether this rule is equal to <tt>other</tt>.
#
- # @param [PublicSuffix::Rule::*] other The rule to compare
- # @return [Boolean]
- # Returns true if this rule and other are instances of the same class
- # and has the same value, false otherwise.
+ # @param other [PublicSuffix::Rule::*] The rule to compare
+ # @return [Boolean] true if this rule and other are instances of the same class
+ # and has the same value, false otherwise.
def ==(other)
equal?(other) || (self.class == other.class && value == other.value)
end
alias eql? ==
@@ -174,11 +173,11 @@
def parts
raise NotImplementedError
end
# @abstract
- # @param [String, #to_s] name The domain name to decompose
+ # @param domain [#to_s] The domain name to decompose
# @return [Array<String, nil>]
def decompose(*)
raise NotImplementedError
end
@@ -194,11 +193,11 @@
value
end
# Decomposes the domain name according to rule properties.
#
- # @param [String, #to_s] name The domain name to decompose
+ # @param domain [#to_s] The domain name to decompose
# @return [Array<String>] The array with [trd + sld, tld].
def decompose(domain)
suffix = parts.join('\.')
matches = domain.to_s.match(/^(.*)\.(#{suffix})$/)
matches ? matches[1..2] : [nil, nil]
@@ -226,10 +225,11 @@
end
# Initializes a new rule.
#
# @param value [String]
+ # @param length [Integer]
# @param private [Boolean]
def initialize(value:, length: nil, private: false)
super(value: value, length: length, private: private)
length or @length += 1 # * counts as 1
end
@@ -241,11 +241,11 @@
value == "" ? STAR : STAR + DOT + value
end
# Decomposes the domain name according to rule properties.
#
- # @param [String, #to_s] name The domain name to decompose
+ # @param domain [#to_s] The domain name to decompose
# @return [Array<String>] The array with [trd + sld, tld].
def decompose(domain)
suffix = ([".*?"] + parts).join('\.')
matches = domain.to_s.match(/^(.*)\.(#{suffix})$/)
matches ? matches[1..2] : [nil, nil]
@@ -264,11 +264,11 @@
# Exception represents an exception rule (e.g. !parliament.uk).
class Exception < Base
# Initializes a new rule from the content.
#
- # @param content [String] the content of the rule
+ # @param content [#to_s] the content of the rule
# @param private [Boolean]
def self.build(content, private: false)
new(value: content.to_s[1..-1], private: private)
end
@@ -279,11 +279,11 @@
BANG + value
end
# Decomposes the domain name according to rule properties.
#
- # @param [String, #to_s] name The domain name to decompose
+ # @param domain [#to_s] The domain name to decompose
# @return [Array<String>] The array with [trd + sld, tld].
def decompose(domain)
suffix = parts.join('\.')
matches = domain.to_s.match(/^(.*)\.(#{suffix})$/)
matches ? matches[1..2] : [nil, nil]
@@ -319,10 +319,10 @@
#
# @example Creates an Exception rule
# PublicSuffix::Rule.factory("!congresodelalengua3.ar")
# # => #<PublicSuffix::Rule::Exception>
#
- # @param [String] content The rule content.
+ # @param content [#to_s] the content of the rule
# @return [PublicSuffix::Rule::*] A rule instance.
def self.factory(content, private: false)
case content.to_s[0, 1]
when STAR
Wildcard