Class: Imap::Backup::Serializer::Imap
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::Imap
- Defined in:
- lib/imap/backup/serializer/imap.rb
Constant Summary collapse
- CURRENT_VERSION =
2
Instance Attribute Summary collapse
-
#folder_path ⇒ Object
readonly
Returns the value of attribute folder_path.
-
#loaded ⇒ Object
readonly
Returns the value of attribute loaded.
Instance Method Summary collapse
- #append(uid) ⇒ Object
- #delete ⇒ Object
- #include?(uid) ⇒ Boolean
- #index(uid) ⇒ Object
-
#initialize(folder_path) ⇒ Imap
constructor
A new instance of Imap.
- #rename(new_path) ⇒ Object
- #uid_validity ⇒ Object
- #uid_validity=(value) ⇒ Object
- #uids ⇒ Object
- #update_uid(old, new) ⇒ Object
- #valid? ⇒ Boolean
- #version ⇒ Object
Constructor Details
#initialize(folder_path) ⇒ Imap
Returns a new instance of Imap.
10 11 12 13 14 15 16 |
# File 'lib/imap/backup/serializer/imap.rb', line 10 def initialize(folder_path) @folder_path = folder_path @loaded = false @uid_validity = nil @uids = nil @version = nil end |
Instance Attribute Details
#folder_path ⇒ Object (readonly)
Returns the value of attribute folder_path.
7 8 9 |
# File 'lib/imap/backup/serializer/imap.rb', line 7 def folder_path @folder_path end |
#loaded ⇒ Object (readonly)
Returns the value of attribute loaded.
8 9 10 |
# File 'lib/imap/backup/serializer/imap.rb', line 8 def loaded @loaded end |
Instance Method Details
#append(uid) ⇒ Object
26 27 28 29 |
# File 'lib/imap/backup/serializer/imap.rb', line 26 def append(uid) uids << uid save end |
#delete ⇒ Object
31 32 33 34 35 |
# File 'lib/imap/backup/serializer/imap.rb', line 31 def delete return if !exist? File.unlink(pathname) end |
#include?(uid) ⇒ Boolean
37 38 39 |
# File 'lib/imap/backup/serializer/imap.rb', line 37 def include?(uid) uids.include?(uid) end |
#index(uid) ⇒ Object
41 42 43 |
# File 'lib/imap/backup/serializer/imap.rb', line 41 def index(uid) uids.find_index(uid) end |
#rename(new_path) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/imap/backup/serializer/imap.rb', line 45 def rename(new_path) if exist? old_pathname = pathname @folder_path = new_path File.rename(old_pathname, pathname) else @folder_path = new_path end end |
#uid_validity ⇒ Object
55 56 57 58 |
# File 'lib/imap/backup/serializer/imap.rb', line 55 def uid_validity ensure_loaded @uid_validity end |
#uid_validity=(value) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/imap/backup/serializer/imap.rb', line 60 def uid_validity=(value) ensure_loaded @uid_validity = value @uids ||= [] save end |
#uids ⇒ Object
67 68 69 70 |
# File 'lib/imap/backup/serializer/imap.rb', line 67 def uids ensure_loaded @uids || [] end |
#update_uid(old, new) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/imap/backup/serializer/imap.rb', line 72 def update_uid(old, new) index = uids.find_index(old.to_i) return if index.nil? uids[index] = new.to_i save end |
#valid? ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'lib/imap/backup/serializer/imap.rb', line 18 def valid? return false if !exist? return false if version != CURRENT_VERSION return false if !uid_validity true end |
#version ⇒ Object
80 81 82 83 |
# File 'lib/imap/backup/serializer/imap.rb', line 80 def version ensure_loaded @version end |