Class: Pipl::Phone

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

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 = {}) ⇒ Phone

Returns a new instance of Phone.



227
228
229
230
231
232
233
234
235
236
237
# File 'lib/pipl/fields.rb', line 227

def initialize(params={})
  super params
  @country_code = params[:country_code]
  @number = params[:number]
  @extension = params[:extension]
  @type = params[:type]
  @raw = params[:raw]
  @display = params[:display]
  @display_international = params[:display_international]
  @voip = params[:@voip] unless params[:@voip].nil?
end

Instance Attribute Details

#country_codeFixnum

Returns International country calling code.

Returns:

  • (Fixnum)

    International country calling code



225
226
227
# File 'lib/pipl/fields.rb', line 225

def country_code
  @country_code
end

#displayString

Returns Well formatted representation of this phone number for display purposes.

Returns:

  • (String)

    Well formatted representation of this phone number for display purposes.



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

attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international, :voip

#display_internationalString

Returns Well formatted international representation of this phone number for display purposes.

Returns:

  • (String)

    Well formatted international representation of this phone number for display purposes.



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

attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international, :voip

#extensionString

Returns Office extension.

Returns:

  • (String)

    Office extension



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

attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international, :voip

#numberFixnum

Returns Actual phone number.

Returns:

  • (Fixnum)

    Actual phone number



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

attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international, :voip

#rawString

Returns Unparsed phone number.

Returns:

  • (String)

    Unparsed phone number



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

attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international, :voip

#typeString

Possible values are:

mobile
home_phone
home_fax
work_phone
work_fax
pager

Returns:

  • (String)

    Type of association of this phone to a person.



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

attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international, :voip

#voipObject

Returns the value of attribute voip.



225
226
227
# File 'lib/pipl/fields.rb', line 225

def voip
  @voip
end

Class Method Details

.extra_metadataObject



239
240
241
# File 'lib/pipl/fields.rb', line 239

def self.
  [:display_international]
end

Instance Method Details

#is_searchable?Boolean

Returns:

  • (Boolean)


248
249
250
# File 'lib/pipl/fields.rb', line 248

def is_searchable?
  (@raw && ! @raw.empty?) || ! @number.nil?
end

#to_hashObject



243
244
245
246
# File 'lib/pipl/fields.rb', line 243

def to_hash
  {country_code: @country_code, number: @number, extension: @extension, raw: @raw}
      .reject { |_, value| value.nil? }
end