Class: LeanMail::Data

Inherits:
Object
  • Object
show all
Defined in:
contrib/lib/lean_mail.rb

Overview

RFC 2821 message data representation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, subject, message) ⇒ Data

Returns a new instance of Data.



36
37
38
39
40
41
# File 'contrib/lib/lean_mail.rb', line 36

def initialize(from, to, subject, message)
  @from = from
  @to = to
  @subject = subject
  @message = message
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



34
35
36
# File 'contrib/lib/lean_mail.rb', line 34

def from
  @from
end

#messageObject (readonly)

Returns the value of attribute message.



34
35
36
# File 'contrib/lib/lean_mail.rb', line 34

def message
  @message
end

#subjectObject (readonly)

Returns the value of attribute subject.



34
35
36
# File 'contrib/lib/lean_mail.rb', line 34

def subject
  @subject
end

#toObject (readonly)

Returns the value of attribute to.



34
35
36
# File 'contrib/lib/lean_mail.rb', line 34

def to
  @to
end

Instance Method Details

#to_sObject



43
44
45
46
47
48
49
50
51
52
53
# File 'contrib/lib/lean_mail.rb', line 43

def to_s
  <<~MAIL
    From: #{@from}
    To: #{to.instance_of?(Array) ? to.join(', ') : to}
    Subject: #{subject}
    Date: #{Time.new.rfc2822}
    Message-Id: <#{SecureRandom.uuid}@#{Socket.gethostname}>

    #{@message}
  MAIL
end