Class: ZeroDrop::Filter
- Inherits:
-
Struct
- Object
- Struct
- ZeroDrop::Filter
- Defined in:
- lib/zerodrop.rb
Overview
Filter for narrowing which email is returned. All string matches are case-insensitive partial matches.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#from ⇒ Object
Returns the value of attribute from.
-
#has_magic_link ⇒ Object
Returns the value of attribute has_magic_link.
-
#has_otp ⇒ Object
Returns the value of attribute has_otp.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
52 53 54 |
# File 'lib/zerodrop.rb', line 52 def body @body end |
#from ⇒ Object
Returns the value of attribute from
52 53 54 |
# File 'lib/zerodrop.rb', line 52 def from @from end |
#has_magic_link ⇒ Object
Returns the value of attribute has_magic_link
52 53 54 |
# File 'lib/zerodrop.rb', line 52 def has_magic_link @has_magic_link end |
#has_otp ⇒ Object
Returns the value of attribute has_otp
52 53 54 |
# File 'lib/zerodrop.rb', line 52 def has_otp @has_otp end |
#subject ⇒ Object
Returns the value of attribute subject
52 53 54 |
# File 'lib/zerodrop.rb', line 52 def subject @subject end |
Instance Method Details
#matches?(email) ⇒ Boolean
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/zerodrop.rb', line 56 def matches?(email) return false if from && !email.from.to_s.downcase.include?(from.downcase) return false if subject && !email.subject.to_s.downcase.include?(subject.downcase) return false if body && !email.body.to_s.downcase.include?(body.downcase) unless has_otp.nil? return false if has_otp && email.otp.to_s.empty? return false if !has_otp && !email.otp.to_s.empty? end unless has_magic_link.nil? return false if has_magic_link && email.magic_link.to_s.empty? return false if !has_magic_link && !email.magic_link.to_s.empty? end true end |