Class: Imap::Backup::Client::Default

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/imap/backup/client/default.rb

Direct Known Subclasses

AppleMail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Default

Returns a new instance of Default.



17
18
19
20
# File 'lib/imap/backup/client/default.rb', line 17

def initialize(*args)
  @args = args
  @state = nil
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



14
15
16
# File 'lib/imap/backup/client/default.rb', line 14

def args
  @args
end

#stateObject

Returns the value of attribute state.



15
16
17
# File 'lib/imap/backup/client/default.rb', line 15

def state
  @state
end

Instance Method Details

#disconnectObject

Track mailbox selection during delegation to Net::IMAP instance



33
34
35
36
# File 'lib/imap/backup/client/default.rb', line 33

def disconnect
  imap.disconnect
  self.state = nil
end

#examine(mailbox) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/imap/backup/client/default.rb', line 38

def examine(mailbox)
  return if state == [:examine, mailbox]

  result = imap.examine(mailbox)
  self.state = [:examine, mailbox]
  result
end

#listObject



22
23
24
25
26
27
28
29
# File 'lib/imap/backup/client/default.rb', line 22

def list
  root = provider_root
  mailbox_lists = imap.list(root, "*")

  return [] if mailbox_lists.nil?

  mailbox_lists.map { |ml| extract_name(ml) }
end

#select(mailbox) ⇒ Object



46
47
48
49
50
51
# File 'lib/imap/backup/client/default.rb', line 46

def select(mailbox)
  return if state == [:select, mailbox]

  imap.select(mailbox)
  self.state = [:select, mailbox]
end