Class: RichEmailValidator::ListValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/rich_email_validator/list_validator.rb

Overview

Validates list of emails and return the valid ones

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list, options = {}) ⇒ ListValidator

Validates list of emails

Parameters:

  • list (Enumerator)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :threads_count (#to_int)

    number of threads that will be fired simultaneously to calculate the result



26
27
28
29
30
31
# File 'lib/rich_email_validator/list_validator.rb', line 26

def initialize(list, options = {})
  @list = list
  @threads_count = options.fetch(:threads_count) { 20 }
  @result = []
  @total_slices = (@list.size / @threads_count.to_f).ceil
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



19
20
21
# File 'lib/rich_email_validator/list_validator.rb', line 19

def list
  @list
end

#threads_countObject (readonly)

Returns the value of attribute threads_count.



19
20
21
# File 'lib/rich_email_validator/list_validator.rb', line 19

def threads_count
  @threads_count
end

Class Method Details

.filter(list, options = {}) ⇒ Array

Validates list of emails

Parameters:

  • list (Enumerator)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :threads_count (#to_int)

    number of threads that will be fired simultaneously to calculate the result

Returns:

  • (Array)


14
15
16
# File 'lib/rich_email_validator/list_validator.rb', line 14

def filter(list, options = {})
  new(list, options).filter
end

Instance Method Details

#filterArray

Validates list of emails

Returns:

  • (Array)


35
36
37
# File 'lib/rich_email_validator/list_validator.rb', line 35

def filter
  @filtered ||= run_filter
end