Class: InboxSync::Notice::Base

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

Direct Known Subclasses

RunSyncError, SyncMailItemError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(smtp, config) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
16
17
18
19
# File 'lib/inbox-sync/notice/base.rb', line 10

def initialize(smtp, config)
  @smtp = smtp
  @config = config

  @mail = ::Mail.new
  @mail.from = self.from
  @mail.to = self.to
  @mail.subject = self.subject
  @mail.body = self.body
end

Instance Attribute Details

#mailObject (readonly)

Returns the value of attribute mail.



8
9
10
# File 'lib/inbox-sync/notice/base.rb', line 8

def mail
  @mail
end

Instance Method Details

#bodyObject

Raises:

  • (RuntimeError)


28
29
30
# File 'lib/inbox-sync/notice/base.rb', line 28

def body
  raise RuntimeError, "subclass `Notice::Base` and define your body"
end

#fromObject



21
# File 'lib/inbox-sync/notice/base.rb', line 21

def from; @config.from_addr; end

#sendObject



32
33
34
35
36
# File 'lib/inbox-sync/notice/base.rb', line 32

def send
  @smtp.start(helo, user, pw, authtype) do |smtp|
    smtp.send_message(@mail.to_s, from, to)
  end
end

#subject(msg = "notice") ⇒ Object



24
25
26
# File 'lib/inbox-sync/notice/base.rb', line 24

def subject(msg="notice")
  "[inbox-sync] #{msg}"
end

#toObject



22
# File 'lib/inbox-sync/notice/base.rb', line 22

def to;   @config.to_addr;   end