Class: MailHandler::Receiving::FolderChecker

Inherits:
Checker
  • Object
show all
Includes:
FileHandling
Defined in:
lib/mailhandler/receiving/folder.rb

Overview

folder checking base class

Constant Summary

Constants inherited from Checker

Checker::AVAILABLE_SEARCH_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from Checker

#available_search_options, #found_emails, #search_options

Instance Method Summary collapse

Methods included from FileHandling

#access_file

Methods inherited from Checker

#reset_found_emails, #search_result, #stop

Constructor Details

#initialize(inbox_folder = nil, archive_folder = nil) ⇒ FolderChecker

Returns a new instance of FolderChecker.



20
21
22
23
24
25
# File 'lib/mailhandler/receiving/folder.rb', line 20

def initialize(inbox_folder = nil, archive_folder = nil)
  super()

  @inbox_folder = inbox_folder
  @archive_folder = archive_folder
end

Instance Attribute Details

#archive_folderObject

folders in which emails will be searched for and managed



17
18
19
# File 'lib/mailhandler/receiving/folder.rb', line 17

def archive_folder
  @archive_folder
end

#inbox_folderObject

folders in which emails will be searched for and managed



17
18
19
# File 'lib/mailhandler/receiving/folder.rb', line 17

def inbox_folder
  @inbox_folder
end

Instance Method Details

#find(options) ⇒ Object

check whether email is received by checking for an email in folder



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mailhandler/receiving/folder.rb', line 28

def find(options)
  verify_and_set_search_options(options)
  verify_mailbox_folders
  email_files = find_files(search_options)

  unless email_files.empty?
    @found_emails = parse_email_from_files(email_files, search_options[:count])
    move_files(email_files) if search_options[:archive]
  end

  search_result
end

#startObject



41
42
43
# File 'lib/mailhandler/receiving/folder.rb', line 41

def start
  verify_mailbox_folders
end