Class: Pipl::Email

Inherits:
Field
  • Object
show all
Defined in:
lib/pipl/fields.rb

Constant Summary collapse

RE_EMAIL =
Regexp.new('^[a-zA-Z0-9\'._%\-+]+@[a-zA-Z0-9._%\-]+\.[a-zA-Z]{2,24}$')

Instance Attribute Summary collapse

Attributes inherited from Field

#current, #inferred, #last_seen, #valid_since

Class Method Summary collapse

Instance Method Summary collapse

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.



272
273
274
275
276
277
278
279
# File 'lib/pipl/fields.rb', line 272

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

#addressString

Returns Plain email address.

Returns:

  • (String)

    Plain email address



270
271
272
# File 'lib/pipl/fields.rb', line 270

def address
  @address
end

#address_md5String

Returns MD5 hash of the email address.

Returns:

  • (String)

    MD5 hash of the email address



270
# File 'lib/pipl/fields.rb', line 270

attr_accessor :address, :address_md5, :type, :disposable, :email_provider

#disposableBoolean

Returns Indicating if this email comes from a disposable email provider.

Returns:

  • (Boolean)

    Indicating if this email comes from a disposable email provider.



270
# File 'lib/pipl/fields.rb', line 270

attr_accessor :address, :address_md5, :type, :disposable, :email_provider

#email_providerBoolean

Returns Indicating if this email comes from a well known email provider like gmail or yahoo.

Returns:

  • (Boolean)

    Indicating if this email comes from a well known email provider like gmail or yahoo.



270
# File 'lib/pipl/fields.rb', line 270

attr_accessor :address, :address_md5, :type, :disposable, :email_provider

#typeString

Returns Type of email association to a person. One of ‘personal` or `work`.

Returns:

  • (String)

    Type of email association to a person. One of ‘personal` or `work`.



270
# File 'lib/pipl/fields.rb', line 270

attr_accessor :address, :address_md5, :type, :disposable, :email_provider

Class Method Details

.extra_metadataObject



281
282
283
# File 'lib/pipl/fields.rb', line 281

def self.
  [:disposable, :email_provider]
end

Instance Method Details

#domainObject



301
302
303
# File 'lib/pipl/fields.rb', line 301

def domain
  @address.split('@')[1] if is_valid_email?
end

#is_searchable?Boolean

Returns:

  • (Boolean)


289
290
291
# File 'lib/pipl/fields.rb', line 289

def is_searchable?
  is_valid_email? || (! @address_md5.nil? && @address_md5.length == 32)
end

#is_valid_email?Boolean

Returns:

  • (Boolean)


285
286
287
# File 'lib/pipl/fields.rb', line 285

def is_valid_email?
  ! RE_EMAIL.match(@address).nil?
end

#to_hashObject



293
294
295
# File 'lib/pipl/fields.rb', line 293

def to_hash
  {address: @address, address_md5: @address_md5}.reject { |_, value| value.nil? }
end

#usernameObject



297
298
299
# File 'lib/pipl/fields.rb', line 297

def username
  @address.split('@')[0] if is_valid_email?
end