function __construct($h = array()) { parent::__construct(); if (array_key_exists('street_number', $h)) { $this->street_number = $h['street_number']; } if (array_key_exists('street_name', $h)) { $this->street_name = $h['street_name']; } if (array_key_exists('street_address', $h)) { $this->street_address = $h['street_address']; if (!isset($this->street_number)) { $this->street_number = $this->street_number(); } if (!isset($this->street_name)) { $this->street_name = $this->street_name(); } } else { #attr_reader :street_number, :street_name if (strlen($this->street_number) > 0) { $this->street_address = $this->street_number; } else { $this->street_address = ''; } if (strlen($this->street_name) > 0) { $this->street_address .= $this->street_name; } } if (array_key_exists('city', $h)) { $this->city = $h['city']; } if (array_key_exists('state', $h)) { $this->state = $h['state']; } if (array_key_exists('zip', $h)) { $this->zip = $h['zip']; } if (array_key_exists('country_code', $h)) { $this->country_code = $h['country_code']; } if (array_key_exists('provider', $h)) { $this->provider = $h['provider']; } if (array_key_exists('success', $h)) { $this->success = $h['success']; } # attr_accessor :success, :provider, :precision if (array_key_exists('precision', $h)) { $this->precision = $h['precision']; } else { if ($this->success || strlen($this->provider) > 0) { $this->precision = $this->success ? 'true' : 'false'; if (strlen($this->provider) > 0) { $this->precision .= ', ' . $this->provider; } } } if (array_key_exists('lat', $h)) { $this->lat = $h['lat']; } if (array_key_exists('lng', $h)) { $this->lng = $h['lng']; } if (array_key_exists('full_address', $h)) { $this->full_address = $h['full_address']; } else { # attr_accessor :street_address, :city, :state, :zip, :country_code, :full_address if (strlen($this->street_address) > 0) { $this->full_address = $this->street_address; } if (strlen($this->city) > 0) { if (strlen($this->full_address) > 0) { $this->full_address .= ', '; } $this->full_address .= $this->city; } if (strlen($this->state) > 0) { if (strlen($this->full_address) > 0) { $this->full_address .= ', '; } $this->full_address .= $this->state; } if (strlen($this->zip) > 0) { if (strlen($this->full_address) > 0) { $this->full_address .= ', '; } $this->full_address .= $this->zip; } if (strlen($this->country_code) > 0) { if (strlen($this->full_address) > 0) { $this->full_address .= ', '; } $this->full_address .= $this->country_code; } } }