2 attr_reader :code, :min_lat, :max_lat, :min_lon, :max_lon
4 def initialize(code, min_lat, max_lat, min_lon, max_lon)
12 def self.find_by_code(code)
17 @countries ||= load_countries
20 def self.load_countries
22 xml = REXML::Document.new(File.read("config/countries.xml"))
24 xml.elements.each("geonames/country") do |ele|
25 code = ele.get_text("countryCode").to_s
26 minlon = ele.get_text("west").to_s
27 minlat = ele.get_text("south").to_s
28 maxlon = ele.get_text("east").to_s
29 maxlat = ele.get_text("north").to_s
31 countries[code] = Country.new(code, minlat.to_f, maxlat.to_f, minlon.to_f, maxlon.to_f)