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.
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_code ⇒ Fixnum
Returns International country calling code.
218 219 220 |
# File 'lib/pipl/fields.rb', line 218 def country_code @country_code end |
#display ⇒ String
Returns 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_international ⇒ String
Returns 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 |
#extension ⇒ String
Returns Office extension.
218 |
# File 'lib/pipl/fields.rb', line 218 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
#number ⇒ Fixnum
Returns Actual phone number.
218 |
# File 'lib/pipl/fields.rb', line 218 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
#raw ⇒ String
Returns Unparsed phone number.
218 |
# File 'lib/pipl/fields.rb', line 218 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
218 |
# File 'lib/pipl/fields.rb', line 218 attr_accessor :country_code, :number, :extension, :type, :raw, :display, :display_international |
Class Method Details
.extra_metadata ⇒ Object
231 232 233 |
# File 'lib/pipl/fields.rb', line 231 def self. [:display_international] end |
Instance Method Details
#is_searchable? ⇒ 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_hash ⇒ Object
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 |