Sha256: 57d0f3a3213de950e0ba82261c38626877b299e20187d54987f2781351807370

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true

require "set"
require "email_inquire/response"

module EmailInquire
  module Validator
    class Base

      class << self

        def validate(email)
          new(email).validate
        end

        private :new

        private

        def load_data(filename)
          data = File.read("#{__dir__}/../../../data/#{filename}.txt")
          lines = data.split("\n")
          lines.reject! { |line| line[0] == "#" }

          lines.to_set
        end

      end

      def initialize(email)
        @email = email
        @name, @domain = email&.split("@", 2)
      end

      attr_reader :domain, :email, :name

      def validate
        raise NotImplementedError
      end

      private

      def response
        @response ||= Response.new(email: email)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
email_inquire-0.11.0 lib/email_inquire/validator/base.rb
email_inquire-0.10.0 lib/email_inquire/validator/base.rb