Class: Pipl::Email
Constant Summary collapse
- RE_EMAIL =
Regexp.new('^[a-zA-Z0-9\'._%\-+]+@[a-zA-Z0-9._%\-]+\.[a-zA-Z]{2,24}$')
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
#current, #inferred, #last_seen, #valid_since
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, extract_rate_limits, is_valid_url?, str_to_date, titleize, to_utf8
Constructor Details
#initialize(params = {}) ⇒ Email
Returns a new instance of Email.
271 272 273 274 275 276 277 278 |
# File 'lib/pipl/fields.rb', line 271 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.
269 270 271 |
# File 'lib/pipl/fields.rb', line 269 def address @address end |
#address_md5 ⇒ String
Returns MD5 hash of the email address.
269 |
# File 'lib/pipl/fields.rb', line 269 attr_accessor :address, :address_md5, :type, :disposable, :email_provider |
#disposable ⇒ Boolean
Returns Indicating if this email comes from a disposable email provider.
269 |
# File 'lib/pipl/fields.rb', line 269 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.
269 |
# File 'lib/pipl/fields.rb', line 269 attr_accessor :address, :address_md5, :type, :disposable, :email_provider |
#type ⇒ String
Returns Type of email association to a person. One of ‘personal` or `work`.
269 |
# File 'lib/pipl/fields.rb', line 269 attr_accessor :address, :address_md5, :type, :disposable, :email_provider |
Class Method Details
.extra_metadata ⇒ Object
280 281 282 |
# File 'lib/pipl/fields.rb', line 280 def self. [:disposable, :email_provider] end |
Instance Method Details
#domain ⇒ Object
300 301 302 |
# File 'lib/pipl/fields.rb', line 300 def domain @address.split('@')[1] if is_valid_email? end |
#is_searchable? ⇒ Boolean
288 289 290 |
# File 'lib/pipl/fields.rb', line 288 def is_searchable? is_valid_email? or (not @address_md5.nil? and @address_md5.length == 32) end |
#is_valid_email? ⇒ Boolean
284 285 286 |
# File 'lib/pipl/fields.rb', line 284 def is_valid_email? not RE_EMAIL.match(@address).nil? end |
#to_hash ⇒ Object
292 293 294 |
# File 'lib/pipl/fields.rb', line 292 def to_hash {address: @address, address_md5: @address_md5}.reject { |_, value| value.nil? } end |
#username ⇒ Object
296 297 298 |
# File 'lib/pipl/fields.rb', line 296 def username @address.split('@')[0] if is_valid_email? end |