Class: Webspicy::Tester::Fakesmtp::Email
- Inherits:
-
Object
- Object
- Webspicy::Tester::Fakesmtp::Email
- Defined in:
- lib/webspicy/tester/fakesmtp/email.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #cc ⇒ Object
- #from ⇒ Object
- #headers ⇒ Object
-
#initialize(data) ⇒ Email
constructor
A new instance of Email.
- #reply_to ⇒ Object
- #subject ⇒ Object
- #to ⇒ Object
Constructor Details
#initialize(data) ⇒ Email
Returns a new instance of Email.
6 7 8 |
# File 'lib/webspicy/tester/fakesmtp/email.rb', line 6 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/webspicy/tester/fakesmtp/email.rb', line 9 def data @data end |
Instance Method Details
#cc ⇒ Object
23 24 25 26 |
# File 'lib/webspicy/tester/fakesmtp/email.rb', line 23 def cc @cc ||= data["cc"]["value"] .map{|h| h["address"] } end |
#from ⇒ Object
11 12 13 14 15 16 |
# 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 ⇒ Object
41 42 43 44 45 46 47 |
# 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 ⇒ Object
28 29 30 31 32 |
# 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 ⇒ Object
34 35 36 37 38 39 |
# File 'lib/webspicy/tester/fakesmtp/email.rb', line 34 def subject @subject ||= data["subject"] || data["headerLines"] .select{|h| h["key"] == "subject" } .map{|h| h["line"][/Subject:\s*(.*)$/, 1] } .first end |
#to ⇒ Object
18 19 20 21 |
# File 'lib/webspicy/tester/fakesmtp/email.rb', line 18 def to @to ||= data["to"]["value"] .map{|h| h["address"] } end |