Class: Email::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/email/provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ Provider

Returns a new instance of Provider.



19
20
21
# File 'lib/email/provider.rb', line 19

def initialize(provider)
  @provider = provider
end

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider.



17
18
19
# File 'lib/email/provider.rb', line 17

def provider
  @provider
end

Class Method Details

.for_address(address) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/email/provider.rb', line 4

def self.for_address(address)
  case
  when address.end_with?("@fastmail.com")
    new(:fastmail)
  when address.end_with?("@gmail.com")
    new(:gmail)
  when address.end_with?("@fastmail.fm")
    new(:fastmail)
  else
    new(:default)
  end
end

Instance Method Details

#hostObject



27
28
29
30
31
32
33
34
# File 'lib/email/provider.rb', line 27

def host
  case provider
  when :gmail
    "imap.gmail.com"
  when :fastmail
    "imap.fastmail.com"
  end
end

#optionsObject



23
24
25
# File 'lib/email/provider.rb', line 23

def options
  {port: 993, ssl: {ssl_version: :TLSv1_2}}
end