Class: USPS::Response::AddressStandardization
- Defined in:
- lib/usps/response/address_standardization.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #addresses ⇒ Object
-
#get(address) ⇒ Object
(also: #[])
Returns an address representing the standardized version of the given address from the results of the query.
-
#initialize(addresses, xml) ⇒ AddressStandardization
constructor
A new instance of AddressStandardization.
- #to_h ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(addresses, xml) ⇒ AddressStandardization
Returns a new instance of AddressStandardization.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/usps/response/address_standardization.rb', line 6 def initialize(addresses, xml) @addresses = {} [addresses].flatten.each_with_index do |addy, i| @addresses[addy] = parse(xml.search("Address[@ID='#{i}']")) # Name is not sent nor received so lets make sure to set it so the # standardized version is roughly equivalent @addresses[addy].name = addy.name end end |
Instance Method Details
#addresses ⇒ Object
25 26 27 |
# File 'lib/usps/response/address_standardization.rb', line 25 def addresses @addresses end |
#get(address) ⇒ Object Also known as: []
Returns an address representing the standardized version of the given address from the results of the query.
20 21 22 |
# File 'lib/usps/response/address_standardization.rb', line 20 def get(address) @addresses[address] end |
#to_h ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/usps/response/address_standardization.rb', line 29 def to_h hash = {} @addresses.each_pair do |key, value| hash[key.to_h] = value.to_h end hash end |