Class: Peoplefinder::EmailAddress
- Inherits:
-
Mail::Address
- Object
- Mail::Address
- Peoplefinder::EmailAddress
- Defined in:
- app/models/peoplefinder/email_address.rb
Constant Summary collapse
- VALID_EMAIL_PATTERN =
/\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/
Instance Method Summary collapse
- #inferred_first_name ⇒ Object
- #inferred_last_name ⇒ Object
-
#initialize(string) ⇒ EmailAddress
constructor
A new instance of EmailAddress.
- #multipart_local? ⇒ Boolean
- #valid_address? ⇒ Boolean
- #valid_domain? ⇒ Boolean
- #valid_format? ⇒ Boolean
Constructor Details
#initialize(string) ⇒ EmailAddress
Returns a new instance of EmailAddress.
6 7 8 9 |
# File 'app/models/peoplefinder/email_address.rb', line 6 def initialize(string) return false unless string =~ VALID_EMAIL_PATTERN super end |
Instance Method Details
#inferred_first_name ⇒ Object
31 32 33 |
# File 'app/models/peoplefinder/email_address.rb', line 31 def inferred_first_name local.split('.')[0] if multipart_local? end |
#inferred_last_name ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/models/peoplefinder/email_address.rb', line 23 def inferred_last_name if multipart_local? local.split('.')[1] else local.split('.')[0] end end |
#multipart_local? ⇒ Boolean
35 36 37 |
# File 'app/models/peoplefinder/email_address.rb', line 35 def multipart_local? local.split('.').length > 1 end |
#valid_address? ⇒ Boolean
19 20 21 |
# File 'app/models/peoplefinder/email_address.rb', line 19 def valid_address? address ? (valid_format? && valid_domain?) : false end |
#valid_domain? ⇒ Boolean
11 12 13 |
# File 'app/models/peoplefinder/email_address.rb', line 11 def valid_domain? valid_login_domains.include?(domain) end |
#valid_format? ⇒ Boolean
15 16 17 |
# File 'app/models/peoplefinder/email_address.rb', line 15 def valid_format? address && address.match(VALID_EMAIL_PATTERN) end |