class PublicSuffix::Rule::Wildcard

Wildcard represents a wildcard rule (e.g. *.co.uk).

Public Class Methods

Initializes a new rule from the content.

@param content [String] the content of the rule @param private [Boolean]

# File lib/public_suffix/rule.rb, line 233
def self.build(content, private: false)
  new(value: content.to_s[2..], private: private)
end

Initializes a new rule.

@param value [String] @param length [Integer] @param private [Boolean]

Calls superclass method PublicSuffix::Rule::Base::new
# File lib/public_suffix/rule.rb, line 242
def initialize(value:, length: nil, private: false)
  super
  length or @length += 1 # * counts as 1
end

Public Instance Methods

Checks if this rule matches name.

The wildcard label needs one label of the name, so the value alone does not match.

@param name [String] the domain name to check @return [Boolean]

Calls superclass method PublicSuffix::Rule::Base#match?
# File lib/public_suffix/rule.rb, line 261
def match?(name)
  return super if value == ""

  name.end_with?(DOT + value)
end

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

@return [Array<String>]

# File lib/public_suffix/rule.rb, line 271
def parts
  @value.split(DOT)
end

Gets the original rule definition.

@return [String] The rule definition.

# File lib/public_suffix/rule.rb, line 250
def rule
  value == "" ? STAR : STAR + DOT + value
end