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(server, account, options) ⇒ Default

Returns a new instance of Default.



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

def initialize(server, , options)
  @account = 
  @options = options
  @server = server
  @state = nil
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



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

def 
  @account
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#serverObject (readonly)

Returns the value of attribute server.



20
21
22
# File 'lib/imap/backup/client/default.rb', line 20

def server
  @server
end

#stateObject

Returns the value of attribute state.



21
22
23
# File 'lib/imap/backup/client/default.rb', line 21

def state
  @state
end

Instance Method Details

#disconnectObject

Track mailbox selection during delegation to Net::IMAP instance



56
57
58
59
# File 'lib/imap/backup/client/default.rb', line 56

def disconnect
  imap.disconnect
  self.state = nil
end

#examine(mailbox) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/imap/backup/client/default.rb', line 61

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

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

#listObject



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

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

  return [] if mailbox_lists.nil?

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

#loginObject



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

def 
  Logger.logger.debug "Logging in: #{.username}/#{masked_password}"
  imap.(.username, .password)
  Logger.logger.debug "Login complete"
end

#reconnectObject



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

def reconnect
  disconnect
  
end

#select(mailbox) ⇒ Object



69
70
71
72
73
74
# File 'lib/imap/backup/client/default.rb', line 69

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

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

#usernameObject



50
51
52
# File 'lib/imap/backup/client/default.rb', line 50

def username
  .username
end