Class: RichEmailValidator::FileValidator

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

Overview

Validate input file emails and save valid ones to another output file

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_file_path, options = {}) ⇒ FileValidator

Validates input from file

Parameters:

  • input_file_path (File)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :threads_count (#to_int)

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



33
34
35
36
# File 'lib/rich_email_validator/file_validator.rb', line 33

def initialize(input_file_path, options = {})
  @input_file_path = input_file_path
  @options = options
end

Instance Attribute Details

#input_file_pathObject (readonly)

Returns the value of attribute input_file_path.



4
5
6
# File 'lib/rich_email_validator/file_validator.rb', line 4

def input_file_path
  @input_file_path
end

Class Method Details

.export_valid_list(input_file_path, output_file_path, options = {}) ⇒ Object

Validates input from file and write to file

Parameters:

  • input_file_path (File)
  • output_file_path (File)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :threads_count (#to_int)

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



23
24
25
# File 'lib/rich_email_validator/file_validator.rb', line 23

def export_valid_list(input_file_path, output_file_path, options = {})
  new(input_file_path, options).export_valid_list(output_file_path)
end

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

Validates input from file

Parameters:

  • input_file_path (File)
  • 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)


13
14
15
# File 'lib/rich_email_validator/file_validator.rb', line 13

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

Instance Method Details

#export_valid_list(output_file_path) ⇒ Object

Validates input from file and writes to file



45
46
47
48
49
# File 'lib/rich_email_validator/file_validator.rb', line 45

def export_valid_list(output_file_path)
  File.open(output_file_path, 'w') do |file|
    filter.each { |email| file.puts(email) }
  end
end

#filterArray

Validates input from file

Returns:

  • (Array)


40
41
42
# File 'lib/rich_email_validator/file_validator.rb', line 40

def filter
  @filtered ||= run_filter
end