Class: Imap::Backup::Account::BackupFolders
- Inherits:
-
Object
- Object
- Imap::Backup::Account::BackupFolders
- Includes:
- Enumerable
- Defined in:
- lib/imap/backup/account/backup_folders.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(client:, account:) ⇒ BackupFolders
constructor
A new instance of BackupFolders.
- #map(&block) ⇒ Object
Constructor Details
#initialize(client:, account:) ⇒ BackupFolders
Returns a new instance of BackupFolders.
14 15 16 17 |
# File 'lib/imap/backup/account/backup_folders.rb', line 14 def initialize(client:, account:) @client = client @account = account end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
11 12 13 |
# File 'lib/imap/backup/account/backup_folders.rb', line 11 def account @account end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
12 13 14 |
# File 'lib/imap/backup/account/backup_folders.rb', line 12 def client @client end |
Instance Method Details
#each(&block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/imap/backup/account/backup_folders.rb', line 19 def each(&block) return enum_for(:each) if !block all_names = client.list configured = case when account.folders&.any? account.folders when account.folder_blacklist [] else all_names end names = if account.folder_blacklist all_names - configured else all_names & configured end names.each { |name| block.call(Account::Folder.new(client, name)) } end |
#map(&block) ⇒ Object
44 45 46 47 48 |
# File 'lib/imap/backup/account/backup_folders.rb', line 44 def map(&block) each.map do |folder| block.call(folder) end end |