Skip to content

Instantly share code, notes, and snippets.

@mcculloughsean
Created June 23, 2010 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcculloughsean/450249 to your computer and use it in GitHub Desktop.
Save mcculloughsean/450249 to your computer and use it in GitHub Desktop.
def extract_location
# <addresses>
# <address addressId="1" phone="708-636-5911" address1="5043 West 111th St" address2="" city="Alsip" state="IL" zip="60803-6074" />
# </addresses>
location = XPath.first @listing, '//address'
address_1 = location.attributes['address1']
address_2 = location.attributes['address2']
city = location.attributes['city']
state = location.attributes['state']
zip = location.attributes['zip']
phone = location.attributes['phone']
# <listing listingId="1821828028" advId="1261712" listingType="topPlacementListing" name="Bruno B's Sandwiches Pizza And Catering">
name = @listing.attributes['name']
@location = {
:name => name,
:address => address_1,
:city => city,
:state => state,
:zip => zip,
:phone => phone,
:source_id => listing_id,
:advertiser_id => Advertiser.find_by_email(SITE_CONFIG['yellow_book_advertiser_email']).id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment