Class: InboxSync::FilterActions

Inherits:
Object
  • Object
show all
Defined in:
lib/inbox-sync/filter_actions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
  @message = message
  @copies  = @flags = []
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/inbox-sync/filter_actions.rb', line 5

def message
  @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

#copiesObject



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

#deleteObject



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

#flagsObject



13
# File 'lib/inbox-sync/filter_actions.rb', line 13

def flags;  @flags.uniq;  end

#mark_readObject



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