class RichEmailValidator::FileValidator
Validate input file emails and save valid ones to another output file
Attributes
input_file_path[R]
Public Class Methods
export_valid_list(input_file_path, output_file_path, options = {})
click to toggle source
Validates input from file and write to file @param input_file_path
[File] @param output_file_path [File] @param [Hash] options @option options [#to_int] :threads_count number of threads that will
be fired simultaneously to calculate the result. Default 20, max 100
# 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 = {})
click to toggle source
Validates input from file @param input_file_path
[File] @param [Hash] options @option options [#to_int] :threads_count number of threads that will
be fired simultaneously to calculate the result. Default 20, max 100
@return [Array]
# File lib/rich_email_validator/file_validator.rb, line 13 def filter(input_file_path, options = {}) new(input_file_path, options).filter end
new(input_file_path, options = {})
click to toggle source
Validates input from file @param input_file_path
[File] @param [Hash] options @option options [#to_int] :threads_count number of threads that will
be fired simultaneously to calculate the result. Default 20, max 100
# 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
Public Instance Methods
export_valid_list(output_file_path)
click to toggle source
Validates input from file and writes to file
# 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
filter()
click to toggle source
Validates input from file @return [Array]
# File lib/rich_email_validator/file_validator.rb, line 40 def filter @filtered ||= run_filter end
Private Instance Methods
run_filter()
click to toggle source
# File lib/rich_email_validator/file_validator.rb, line 53 def run_filter list = File.readlines(@input_file_path).map(&:chomp) ListValidator.filter(list, @options) end