Class: MailCapture::Capture
- Inherits:
-
Object
- Object
- MailCapture::Capture
- Defined in:
- lib/mailcapture/models.rb
Overview
A captured email.
email = mc.wait_for('signup')
email.otp # => "123456"
email.subject # => "Verify your account"
email.latency_ms # => 145
Instance Attribute Summary collapse
-
#body_html ⇒ String?
readonly
HTML body, or nil if not present.
-
#body_text ⇒ String?
readonly
Plain-text body, or nil if not present.
-
#id ⇒ String
readonly
Unique capture ID.
-
#latency_ms ⇒ Integer
readonly
Send-to-capture latency in milliseconds.
-
#otp ⇒ String?
readonly
Extracted OTP/code, or nil if none detected.
-
#received_at ⇒ String
readonly
ISO 8601 timestamp of when the email was received.
-
#status ⇒ String
readonly
Delivery status, e.g.
-
#subject ⇒ String
readonly
Email subject line.
-
#tag ⇒ String
readonly
Tag portion of the address, e.g.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Capture
constructor
A new instance of Capture.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(data) ⇒ Capture
Returns a new instance of Capture.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mailcapture/models.rb', line 40 def initialize(data) @id = data['id'] @tag = data['tag'] @subject = data['subject'] @otp = data['otp'] @body_text = data['body_text'] @body_html = data['body_html'] @latency_ms = data['latency_ms'] @status = data['status'] @received_at = data['received_at'] end |
Instance Attribute Details
#body_html ⇒ String? (readonly)
Returns HTML body, or nil if not present.
28 29 30 |
# File 'lib/mailcapture/models.rb', line 28 def body_html @body_html end |
#body_text ⇒ String? (readonly)
Returns plain-text body, or nil if not present.
26 27 28 |
# File 'lib/mailcapture/models.rb', line 26 def body_text @body_text end |
#id ⇒ String (readonly)
Returns unique capture ID.
18 19 20 |
# File 'lib/mailcapture/models.rb', line 18 def id @id end |
#latency_ms ⇒ Integer (readonly)
Returns send-to-capture latency in milliseconds.
30 31 32 |
# File 'lib/mailcapture/models.rb', line 30 def latency_ms @latency_ms end |
#otp ⇒ String? (readonly)
Returns extracted OTP/code, or nil if none detected.
24 25 26 |
# File 'lib/mailcapture/models.rb', line 24 def otp @otp end |
#received_at ⇒ String (readonly)
Returns ISO 8601 timestamp of when the email was received.
34 35 36 |
# File 'lib/mailcapture/models.rb', line 34 def received_at @received_at end |
#status ⇒ String (readonly)
Returns delivery status, e.g. “captured”.
32 33 34 |
# File 'lib/mailcapture/models.rb', line 32 def status @status end |
#subject ⇒ String (readonly)
Returns email subject line.
22 23 24 |
# File 'lib/mailcapture/models.rb', line 22 def subject @subject end |
#tag ⇒ String (readonly)
Returns tag portion of the address, e.g. “signup”.
20 21 22 |
# File 'lib/mailcapture/models.rb', line 20 def tag @tag end |
Class Method Details
.from_hash(data) ⇒ Object
36 37 38 |
# File 'lib/mailcapture/models.rb', line 36 def self.from_hash(data) new(data) end |
Instance Method Details
#to_s ⇒ Object Also known as: inspect
52 53 54 |
# File 'lib/mailcapture/models.rb', line 52 def to_s "#<MailCapture::Capture id=#{id.inspect} tag=#{tag.inspect} subject=#{subject.inspect}>" end |