Class: MailBounce::Status
- Inherits:
-
Object
- Object
- MailBounce::Status
- Defined in:
- lib/mailbounce/status.rb
Overview
Enhanced status code (RFC 3463): class.subject.detail.
Constant Summary collapse
- PATTERN =
Only where a status belongs — not dotted quads in diagnostics (5.1.1.10 is an address). Misses a bare
smtp; 5.1.1 …; that deferral is cheaper than retiring a mailbox over a host IP read as a status. / (?: \A[ \t]* | [245]\d\d[ \t\-]+ | ^Status[ \t]*:[ \t]* ) (?<code>[245]\.\d{1,3}\.\d{1,3}) (?!\.\d) /xi- PERMANENT_CLASS =
"5".freeze
- TRANSIENT_CLASS =
"4".freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
-
#condition ⇒ Object
Class dropped: 5.1.1 and 4.1.1 share condition "1.1".
-
#initialize(code) ⇒ Status
constructor
A new instance of Status.
- #permanent? ⇒ Boolean
- #subject ⇒ Object
- #to_s ⇒ Object
- #transient? ⇒ Boolean
Constructor Details
#initialize(code) ⇒ Status
Returns a new instance of Status.
24 25 26 |
# File 'lib/mailbounce/status.rb', line 24 def initialize(code) @code = code.to_s end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
22 23 24 |
# File 'lib/mailbounce/status.rb', line 22 def code @code end |
Class Method Details
.parse(text) ⇒ Object
16 17 18 19 20 |
# File 'lib/mailbounce/status.rb', line 16 def self.parse(text) if code = text.to_s[PATTERN, :code] new(code) end end |
Instance Method Details
#condition ⇒ Object
Class dropped: 5.1.1 and 4.1.1 share condition "1.1".
37 38 39 |
# File 'lib/mailbounce/status.rb', line 37 def condition parts.drop(1).join(".") end |
#permanent? ⇒ Boolean
28 29 30 |
# File 'lib/mailbounce/status.rb', line 28 def permanent? status_class == PERMANENT_CLASS end |
#subject ⇒ Object
41 42 43 |
# File 'lib/mailbounce/status.rb', line 41 def subject parts[1].to_s end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/mailbounce/status.rb', line 45 def to_s code end |
#transient? ⇒ Boolean
32 33 34 |
# File 'lib/mailbounce/status.rb', line 32 def transient? status_class == TRANSIENT_CLASS end |