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)
19 @@countries ||= load_countries
22 def self.load_countries
24 xml = REXML::Document.new(File.read("config/countries.xml"))
26 xml.elements.each("geonames/country") do |ele|
27 code = ele.get_text("countryCode").to_s
28 minlon = ele.get_text("west").to_s
29 minlat = ele.get_text("south").to_s
30 maxlon = ele.get_text("east").to_s
31 maxlat = ele.get_text("north").to_s
33 countries[code] = Country.new(code, minlat.to_f, maxlat.to_f, minlon.to_f, maxlon.to_f)