class Pipl::Address
Attributes
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
@!attribute country
@return [String] 2 letters country code
@!attribute state
@return [String] 2 letters state code
@!attribute city
@return [String] City
@!attribute street
@return [String] Street
@!attribute house
@return [String] House
@!attribute apartment
@return [String] Apartment
@!attribute zip_code
@return [String] Zip Code
@!attribute po_box
@return [String] Post Office box number
@!attribute type
@return [String] Type of association of this address to a person. One of `home`, `work` or `old`.
@!attribute raw
@return [String] Unparsed address.
@!attribute display
@return [String] well formatted representation of this address for display purposes.
Public Class Methods
Pipl::Field::new
# File lib/pipl/fields.rb, line 133 def initialize(params={}) super params @country = params[:country] @state = params[:state] @city = params[:city] @street = params[:street] @house = params[:house] @apartment = params[:apartment] @zip_code = params[:zip_code] @po_box = params[:po_box] @type = params[:type] @raw = params[:raw] @display = params[:display] end
Public Instance Methods
# File lib/pipl/fields.rb, line 171 def country_full Pipl::COUNTRIES[@country.upcase.to_sym] if @country end
# File lib/pipl/fields.rb, line 163 def is_searchable? [@raw, @country, @state, @city].any? {|x| not x.to_s.empty?} end
# File lib/pipl/fields.rb, line 167 def is_sole_searchable? not @raw.to_s.empty? or [@city, @street, @house].all? {|x| not x.to_s.empty?} end
# File lib/pipl/fields.rb, line 148 def is_valid_country? @country and Pipl::COUNTRIES.key? @country.upcase.to_sym end
# File lib/pipl/fields.rb, line 152 def is_valid_state? is_valid_country? and Pipl::STATES.key?(@country.upcase.to_sym) and @state and Pipl::STATES[@country.upcase.to_sym].key?(@state.upcase.to_sym) end
# File lib/pipl/fields.rb, line 175 def state_full Pipl::STATES[@country.upcase.to_sym][@state.upcase.to_sym] if is_valid_state? end
# File lib/pipl/fields.rb, line 157 def to_hash {country: @country, state: @state, city: @city, street: @street, house: @house, apartment: @apartment, zip_code: @zip_code, po_box: @po_box, raw: @raw} .reject { |_, value| value.nil? } end
# File lib/pipl/fields.rb, line 179 def to_s return @display if @display country = @state ? @country : country_full state = @city ? @state : state_full vals = [@street, @city, state, country] s = vals.any? ? vals.select { |v| v }.join(', ') : '' if @street and (@house or @apartment) prefix = [@house, @apartment].select { |v| v and not v.empty? }.join('-') s = prefix + ' ' + (s || '') end if @po_box and @street.nil? s = "P.O. Box #{@po_box} " + (s || '') end s ? Pipl::Utils.to_utf8(s) : '' end