lib/songkickr/location.rb in songkickr-0.3.3 vs lib/songkickr/location.rb in songkickr-0.4.0

- old
+ new

@@ -21,24 +21,24 @@ # } # # http://www.songkick.com/developer/location-search class Location attr_accessor :city, :lat, :lng, :metro_area - + # Takes a location hash. Handles the different city hashes from Event and Location def initialize(location_hash) if location_hash["city"].is_a?(String) # location in Event @city = location_hash["city"] @lat = location_hash["lat"] @lng = location_hash["lng"] elsif location_hash["city"].is_a?(Hash) # stand-alone Location city_hash = location_hash["city"] - @city = city_hash["displayName"] + @city = city_hash["displayName"] if city_hash && city_hash["displayName"] # some locations have a null lng, lat in city hash, but have non-null in metroArea hash @lat = city_hash["lat"] @lng = city_hash["lng"] end - - @metro_area = location_hash['metroArea'] + + @metro_area = MetroArea.new location_hash['metroArea'] if location_hash.include? 'metroArea' end end end