class Webspicy::Tester::Fakesmtp::Email

Attributes

data[R]

Public Class Methods

new(data) click to toggle source
# File lib/webspicy/tester/fakesmtp/email.rb, line 6
def initialize(data)
  @data = data
end

Public Instance Methods

cc() click to toggle source
# File lib/webspicy/tester/fakesmtp/email.rb, line 23
def cc
  @cc ||= data["cc"]["value"]
    .map{|h| h["address"] }
end
from() click to toggle source
# File lib/webspicy/tester/fakesmtp/email.rb, line 11
def from
  @from ||= data["headerLines"]
    .select{|h| h["key"] == "from" }
    .map{|h| h["line"][/From:\s*(.*)$/, 1] }
    .first
end
headers() click to toggle source
# File lib/webspicy/tester/fakesmtp/email.rb, line 41
def headers
  @headers ||= data["headerLines"]
    .reduce(OpenStruct.new){|acc, h|
      acc[h["key"].downcase] = h["line"].split(': ')[1..].join(': ')
      acc
    }
end
reply_to() click to toggle source
# File lib/webspicy/tester/fakesmtp/email.rb, line 28
def reply_to
  @reply_to ||= data["headerLines"]
    .select{|h| h["key"] == "reply-to" }
    .map{|h| h["line"][/Reply-To:\s*(.*)$/, 1] }
end
subject() click to toggle source
# File lib/webspicy/tester/fakesmtp/email.rb, line 34
def subject
  @subject ||= data["headerLines"]
    .select{|h| h["key"] == "subject" }
    .map{|h| h["line"][/Subject:\s*(.*)$/, 1] }
    .first
end
to() click to toggle source
# File lib/webspicy/tester/fakesmtp/email.rb, line 18
def to
  @to ||= data["to"]["value"]
    .map{|h| h["address"] }
end