Class: InboxSync::FilterActions
- Inherits:
-
Object
- Object
- InboxSync::FilterActions
- Defined in:
- lib/inbox-sync/filter_actions.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #apply!(imap, uid) ⇒ Object
- #copies ⇒ Object
- #copy_to(*folders) ⇒ Object (also: #label)
- #delete ⇒ Object
- #flag(*flags) ⇒ Object
- #flags ⇒ Object
-
#initialize(message) ⇒ FilterActions
constructor
A new instance of FilterActions.
- #mark_read ⇒ Object
- #match!(filters) ⇒ Object
- #move_to(*folders) ⇒ Object (also: #archive_to)
Constructor Details
#initialize(message) ⇒ FilterActions
Returns a new instance of FilterActions.
7 8 9 10 |
# File 'lib/inbox-sync/filter_actions.rb', line 7 def initialize() @message = @copies = @flags = [] end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/inbox-sync/filter_actions.rb', line 5 def @message end |
Instance Method Details
#apply!(imap, uid) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/inbox-sync/filter_actions.rb', line 44 def apply!(imap, uid) apply_flags(imap, uid) apply_copies(imap, uid) # force make the dest message unread if not explicitly marked :Seen if !flags.include?(:Seen) imap.uid_store(uid, "-FLAGS", [:Seen]) end end |
#copies ⇒ Object
12 |
# File 'lib/inbox-sync/filter_actions.rb', line 12 def copies; @copies.uniq; end |
#copy_to(*folders) ⇒ Object Also known as: label
15 16 17 |
# File 'lib/inbox-sync/filter_actions.rb', line 15 def copy_to(*folders) @copies += args_collection(folders) end |
#delete ⇒ Object
34 35 36 |
# File 'lib/inbox-sync/filter_actions.rb', line 34 def delete flag(:Deleted) end |
#flag(*flags) ⇒ Object
26 27 28 |
# File 'lib/inbox-sync/filter_actions.rb', line 26 def flag(*flags) @flags += args_collection(flags).map{|f| f.to_sym} end |
#flags ⇒ Object
13 |
# File 'lib/inbox-sync/filter_actions.rb', line 13 def flags; @flags.uniq; end |
#mark_read ⇒ Object
30 31 32 |
# File 'lib/inbox-sync/filter_actions.rb', line 30 def mark_read flag(:Seen) end |
#match!(filters) ⇒ Object
38 39 40 41 42 |
# File 'lib/inbox-sync/filter_actions.rb', line 38 def match!(filters) filters.each do |filter| instance_eval(&filter.actions) if filter.match?(@message) end end |
#move_to(*folders) ⇒ Object Also known as: archive_to
20 21 22 23 |
# File 'lib/inbox-sync/filter_actions.rb', line 20 def move_to(*folders) copy_to *folders delete end |