class Pipl::Address

Attributes

apartment[RW]

@!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.
city[RW]

@!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.
country[RW]

@!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.
display[RW]

@!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.
house[RW]

@!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.
po_box[RW]

@!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.
raw[RW]

@!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.
state[RW]

@!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.
street[RW]

@!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.
type[RW]

@!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.
zip_code[RW]

@!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

new(params={}) click to toggle source
Calls superclass method 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

country_full() click to toggle source
# File lib/pipl/fields.rb, line 171
def country_full
  Pipl::COUNTRIES[@country.upcase.to_sym] if @country
end
is_searchable?() click to toggle source
# File lib/pipl/fields.rb, line 163
def is_searchable?
  [@raw, @country, @state, @city].any? {|x| not x.to_s.empty?}
end
is_sole_searchable?() click to toggle source
# 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
is_valid_country?() click to toggle source
# File lib/pipl/fields.rb, line 148
def is_valid_country?
  @country and Pipl::COUNTRIES.key? @country.upcase.to_sym
end
is_valid_state?() click to toggle source
# 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
state_full() click to toggle source
# 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
to_hash() click to toggle source
# 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
to_s() click to toggle source
# 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