Class: Dominion::DomainSuffixRule
- Inherits:
-
Object
- Object
- Dominion::DomainSuffixRule
- Defined in:
- lib/dominion/domain_suffix_rule.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
-
#=~(domain) ⇒ Object
match against a domain name.
-
#initialize(s) ⇒ DomainSuffixRule
constructor
A new instance of DomainSuffixRule.
- #inspect ⇒ Object
Constructor Details
#initialize(s) ⇒ DomainSuffixRule
Returns a new instance of DomainSuffixRule.
8 9 10 11 12 13 |
# File 'lib/dominion/domain_suffix_rule.rb', line 8 def initialize(s) @string = s.strip.gsub(/\A\.|\.\z/, '') @labels = @string.split(/\A!|\./).reverse @exception = @labels.last.empty? and @labels.pop @length = @labels.length - (@exception ? 1 : 0) end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
6 7 8 |
# File 'lib/dominion/domain_suffix_rule.rb', line 6 def exception @exception end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
6 7 8 |
# File 'lib/dominion/domain_suffix_rule.rb', line 6 def labels @labels end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
6 7 8 |
# File 'lib/dominion/domain_suffix_rule.rb', line 6 def length @length end |
Instance Method Details
#=~(domain) ⇒ Object
match against a domain name. the domain must be an instance of DomainName
16 17 18 |
# File 'lib/dominion/domain_suffix_rule.rb', line 16 def =~(domain) labels.zip(domain.labels).all? { |r, d| ["*", d].include? r } end |
#inspect ⇒ Object
20 21 22 |
# File 'lib/dominion/domain_suffix_rule.rb', line 20 def inspect @string end |