Class: PublicSuffix::Rule::Normal
- Defined in:
- lib/public_suffix/rule.rb
Overview
Normal represents a standard rule (e.g. com).
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#decompose(domain) ⇒ Array<String>
Decomposes the domain name according to rule properties.
-
#initialize(definition, **options) ⇒ Normal
constructor
Initializes a new rule from
definition
. -
#length ⇒ Integer
Gets the length of this rule for comparison, represented by the number of dot-separated parts in the rule.
-
#parts ⇒ Array<String>
dot-split rule value and returns all rule parts in the order they appear in the value.
-
#rule ⇒ String
Gets the original rule definition.
Methods inherited from Base
Constructor Details
#initialize(definition, **options) ⇒ Normal
Initializes a new rule from definition
.
181 182 183 |
# File 'lib/public_suffix/rule.rb', line 181 def initialize(definition, **) super(definition, **) end |
Instance Method Details
#decompose(domain) ⇒ Array<String>
Decomposes the domain name according to rule properties.
196 197 198 199 200 |
# File 'lib/public_suffix/rule.rb', line 196 def decompose(domain) suffix = parts.join('\.') matches = domain.to_s.match(/^(.*)\.(#{suffix})$/) matches ? matches[1..2] : [nil, nil] end |
#length ⇒ Integer
Gets the length of this rule for comparison, represented by the number of dot-separated parts in the rule.
214 215 216 |
# File 'lib/public_suffix/rule.rb', line 214 def length @length ||= parts.length end |
#parts ⇒ Array<String>
dot-split rule value and returns all rule parts in the order they appear in the value.
206 207 208 |
# File 'lib/public_suffix/rule.rb', line 206 def parts @value.split(DOT) end |
#rule ⇒ String
Gets the original rule definition.
188 189 190 |
# File 'lib/public_suffix/rule.rb', line 188 def rule value end |