Class: EmailInquire::Inquirer

Inherits:
Object
  • Object
show all
Defined in:
lib/email_inquire/inquirer.rb

Constant Summary collapse

VALIDATORS =
[
  # Format first
  EmailInquire::Validator::EmailFormat,

  # Custom overrides
  EmailInquire::Validator::CustomValidDomain,
  EmailInquire::Validator::CustomInvalidDomain,

  # Always valid domains
  EmailInquire::Validator::CommonProvider,

  # Invalid domains
  EmailInquire::Validator::KnownInvalidDomain,
  EmailInquire::Validator::OneTimeProvider,

  # Hints
  EmailInquire::Validator::CommonProviderMistake,
  EmailInquire::Validator::CommonlyMistakenDomain,
  EmailInquire::Validator::CommonlyMistakenTld,
  EmailInquire::Validator::CountryCodeTld,
  EmailInquire::Validator::UniqueDomainProvider,
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email) ⇒ Inquirer

Returns a new instance of Inquirer.



43
44
45
# File 'lib/email_inquire/inquirer.rb', line 43

def initialize(email)
  @email = email&.downcase
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



47
48
49
# File 'lib/email_inquire/inquirer.rb', line 47

def email
  @email
end

Instance Method Details

#validateObject



49
50
51
52
53
# File 'lib/email_inquire/inquirer.rb', line 49

def validate
  response = Helper.first_value(VALIDATORS) { |validator| validator.validate(email) }

  response || Response.new(email: email).valid!
end