class EmailAssessor::DomainTokenSet
Public Class Methods
Source
# File lib/email_assessor/domain_token_set.rb, line 41 def initialize(indexed_tokens) @indexed_tokens = indexed_tokens @indexes = nil # Shape friendliness end
Source
# File lib/email_assessor/domain_token_set.rb, line 6 def parse(domain) parts = domain.downcase.split(".") indexed_tokens = { # {first_char} => { {segment} => nil } } parts.length.times do segment = parts.join(".").freeze (indexed_tokens[segment.chr] ||= Hash.new)[segment] = nil parts.shift end indexed_tokens.each_value(&:freeze) indexed_tokens.freeze new(indexed_tokens) end
Public Instance Methods
Source
# File lib/email_assessor/domain_token_set.rb, line 27 def include?(domain) tokens_of_char = @indexed_tokens[domain.chr] return false if tokens_of_char.nil? tokens_of_char.key?(domain) end
Source
# File lib/email_assessor/domain_token_set.rb, line 35 def indexes @indexes ||= @indexed_tokens.keys end