Class: Pipl::Phone
Instance Attribute Summary collapse
-
#country_code ⇒ Fixnum
International country calling code.
-
#display ⇒ String
Well formatted representation of this phone number for display purposes.
-
#display_international ⇒ String
Well formatted international representation of this phone number for display purposes.
-
#extension ⇒ String
Office extension.
-
#number ⇒ Fixnum
Actual phone number.
-
#raw ⇒ String
Unparsed phone number.
-
#type ⇒ String
Possible values are: mobile home_phone home_fax work_phone work_fax pager.
Attributes inherited from Field
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Phone
constructor
A new instance of Phone.
- #is_searchable? ⇒ Boolean
- #to_hash ⇒ Object
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.
219 220 221 222 223 224 225 226 227 228 |
# File 'lib/pipl/fields.rb', line 219 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_code ⇒ Fixnum
Returns International country calling code.
217 218 219 |
# File 'lib/pipl/fields.rb', line 217 def country_code @country_code end |
#display ⇒ String
Returns Well formatted representation of this phone number for display purposes.
217 |
# File 'lib/pipl/fields.rb', line 217 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
#display_international ⇒ String
Returns Well formatted international representation of this phone number for display purposes.
217 |
# File 'lib/pipl/fields.rb', line 217 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
#extension ⇒ String
Returns Office extension.
217 |
# File 'lib/pipl/fields.rb', line 217 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
#number ⇒ Fixnum
Returns Actual phone number.
217 |
# File 'lib/pipl/fields.rb', line 217 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
#raw ⇒ String
Returns Unparsed phone number.
217 |
# File 'lib/pipl/fields.rb', line 217 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
#type ⇒ String
Possible values are:
mobile
home_phone
home_fax
work_phone
work_fax
pager
217 |
# File 'lib/pipl/fields.rb', line 217 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
Class Method Details
.extra_metadata ⇒ Object
230 231 232 |
# File 'lib/pipl/fields.rb', line 230 def self. [:display_international] end |
Instance Method Details
#is_searchable? ⇒ Boolean
239 240 241 |
# File 'lib/pipl/fields.rb', line 239 def is_searchable? (@raw and not @raw.empty?) or not @number.nil? end |
#to_hash ⇒ Object
234 235 236 237 |
# File 'lib/pipl/fields.rb', line 234 def to_hash {country_code: @country_code, number: @number, extension: @extension, raw: @raw} .reject { |_, value| value.nil? } end |