Class: Pipl::Email

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Attributes inherited from Field

#inferred, #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, 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

#addressString

Returns Plain email address.

Returns:

  • (String)

    Plain email address



262
263
264
# File 'lib/pipl/fields.rb', line 262

def address
  @address
end

#address_md5String

Returns MD5 hash of the email address.

Returns:

  • (String)

    MD5 hash of the email address



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

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.



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

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.



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

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`.



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

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

Class Method Details

.extra_metadataObject



273
274
275
# File 'lib/pipl/fields.rb', line 273

def self.
  [:disposable, :email_provider]
end

Instance Method Details

#domainObject



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

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

#is_searchable?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


277
278
279
# File 'lib/pipl/fields.rb', line 277

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

#to_hashObject



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

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

#usernameObject



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

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