Class: Pipl::Email
Constant Summary collapse
- RE_EMAIL =
Regexp.new('^[\w.%\-+]+@[\w.%\-]+\.[a-zA-Z]{2,6}$')
Instance Attribute Summary collapse
-
#address ⇒ String
Plain email address.
-
#address_md5 ⇒ String
MD5 hash of the email address.
-
#disposable ⇒ Boolean
Indicating if this email comes from a disposable email provider.
-
#email_provider ⇒ Boolean
Indicating if this email comes from a well known email provider like gmail or yahoo.
-
#type ⇒ String
Type of email association to a person.
Attributes inherited from Field
Class Method Summary collapse
Instance Method Summary collapse
- #domain ⇒ Object
-
#initialize(params = {}) ⇒ Email
constructor
A new instance of Email.
- #is_searchable? ⇒ Boolean
- #is_valid_email? ⇒ Boolean
- #to_hash ⇒ Object
- #username ⇒ Object
Methods inherited from Field
base_params_from_hash, from_hash
Methods included from Utils
alnum_chars, alpha_chars, date_to_str, is_valid_url?, str_to_date, titleize, to_utf8
Constructor Details
#initialize(params = {}) ⇒ Email
Returns a new instance of Email.
264 265 266 267 268 269 270 271 |
# File 'lib/pipl/fields.rb', line 264 def initialize(params={}) super params @address = params[:address] @address_md5 = params[:address_md5] @type = params[:type] @disposable = params[:disposable] @email_provider = params[:email_provider] end |
Instance Attribute Details
#address ⇒ String
Returns Plain email address.
262 263 264 |
# File 'lib/pipl/fields.rb', line 262 def address @address end |
#address_md5 ⇒ String
Returns MD5 hash of the email address.
262 |
# File 'lib/pipl/fields.rb', line 262 attr_accessor :address, :address_md5, :type, :disposable, :email_provider |
#disposable ⇒ Boolean
Returns Indicating if this email comes from a disposable email provider.
262 |
# File 'lib/pipl/fields.rb', line 262 attr_accessor :address, :address_md5, :type, :disposable, :email_provider |
#email_provider ⇒ Boolean
Returns Indicating if this email comes from a well known email provider like gmail or yahoo.
262 |
# File 'lib/pipl/fields.rb', line 262 attr_accessor :address, :address_md5, :type, :disposable, :email_provider |
#type ⇒ String
Returns Type of email association to a person. One of ‘personal` or `work`.
262 |
# File 'lib/pipl/fields.rb', line 262 attr_accessor :address, :address_md5, :type, :disposable, :email_provider |
Class Method Details
.extra_metadata ⇒ Object
273 274 275 |
# File 'lib/pipl/fields.rb', line 273 def self. [:disposable, :email_provider] end |
Instance Method Details
#domain ⇒ Object
293 294 295 |
# File 'lib/pipl/fields.rb', line 293 def domain @address.split('@')[1] if is_valid_email? end |
#is_searchable? ⇒ Boolean
281 282 283 |
# File 'lib/pipl/fields.rb', line 281 def is_searchable? is_valid_email? or (not @address_md5.nil? and @address_md5.length == 32) end |
#is_valid_email? ⇒ Boolean
277 278 279 |
# File 'lib/pipl/fields.rb', line 277 def is_valid_email? not RE_EMAIL.match(@address).nil? end |
#to_hash ⇒ Object
285 286 287 |
# File 'lib/pipl/fields.rb', line 285 def to_hash {address: @address, address_md5: @address_md5}.reject { |_, value| value.nil? } end |
#username ⇒ Object
289 290 291 |
# File 'lib/pipl/fields.rb', line 289 def username @address.split('@')[0] if is_valid_email? end |