Class: Pipl::Phone

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

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

Returns a new instance of Phone.



220
221
222
223
224
225
226
227
228
229
# File 'lib/pipl/fields.rb', line 220

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]
end

Instance Attribute Details

#country_codeFixnum

Returns International country calling code.

Returns:

  • (Fixnum)

    International country calling code



218
219
220
# File 'lib/pipl/fields.rb', line 218

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.



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

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

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



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

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

#extensionString

Returns Office extension.

Returns:

  • (String)

    Office extension



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

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

#numberFixnum

Returns Actual phone number.

Returns:

  • (Fixnum)

    Actual phone number



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

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

#rawString

Returns Unparsed phone number.

Returns:

  • (String)

    Unparsed phone number



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

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

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



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

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

Class Method Details

.extra_metadataObject



231
232
233
# File 'lib/pipl/fields.rb', line 231

def self.
  [:display_international]
end

Instance Method Details

#is_searchable?Boolean

Returns:

  • (Boolean)


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

def is_searchable?
  (@raw and not @raw.empty?) or not @number.nil?
end

#to_hashObject



235
236
237
238
# File 'lib/pipl/fields.rb', line 235

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