class AdWords::Db
Public Class Methods
new()
click to toggle source
# File lib/adwords_location/db.rb, line 9 def initialize @location_db = LocationDb.new @postal_code_db = PostalCodeDb.new end
Public Instance Methods
zipcode_city_dma()
click to toggle source
# File lib/adwords_location/db.rb, line 23 def zipcode_city_dma city_data = {} dma_data = {} other = {} @location_db.all_postal_code_records.each do |id, record| @postal_code_db.cities_by_postal_code(record.postal_code).each do |city_cname| city_record = @location_db.find_by_canonical_name city_cname if city_record.nil? other[record.postal_code] = [] else dma_records = @location_db.dmas_by_city(city_record.criteria_id); if dma_records.size > 0 dma_records.each do |d| dma_data[record.postal_code] = [city_record.criteria_id, d.criteria_id] end else city_data[record.postal_code] = [city_record.criteria_id] end end end end [city_data, dma_data, other] end
zipcode_state_country()
click to toggle source
# File lib/adwords_location/db.rb, line 14 def zipcode_state_country data = {} @location_db.all_postal_code_records.each do |id, record| path = @location_db.path id data[record.postal_code] = path end data end