Class: Imap::Backup::Setup::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/setup/email.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account:, config:) ⇒ Email

Returns a new instance of Email.


10
11
12
13
# File 'lib/imap/backup/setup/email.rb', line 10

def initialize(account:, config:)
  @account = 
  @config = config
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.


7
8
9
# File 'lib/imap/backup/setup/email.rb', line 7

def 
  @account
end

#configObject (readonly)

Returns the value of attribute config.


8
9
10
# File 'lib/imap/backup/setup/email.rb', line 8

def config
  @config
end

Instance Method Details

#runObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/imap/backup/setup/email.rb', line 15

def run
  username = Setup::Asker.email(.username)
  other_accounts = config.accounts.reject { |a| a ==  }
  others = other_accounts.map(&:username)
  if others.include?(username)
    Kernel.puts(
      "There is already an account set up with that email address"
    )
  else
    .username = username
    if .server.nil? || (.server == "")
      default = default_server(username)
      .server = default if default
    end
  end
end