class Location
Constants
- MARKERS_URL
Attributes
abbr[RW]
city[RW]
lat[RW]
long[RW]
name[RW]
state[RW]
street_address[RW]
zip[RW]
Public Class Methods
markers_hash()
click to toggle source
# File lib/purlocation/location.rb, line 9 def self.markers_hash @markers_hash ||= populate_markers end
new(abbr)
click to toggle source
# File lib/purlocation/location.rb, line 19 def initialize abbr @me = self.class.markers_hash.select do |marker| marker["@abbreviation"] == abbr end.first @me.keys.each do |k| meth = k[1..-1] self.class.send( :define_method, meth ) do return @me["@#{meth}"] end end end
populate_markers()
click to toggle source
# File lib/purlocation/location.rb, line 13 def self.populate_markers xml_data = Net::HTTP.get_response(URI.parse(MARKERS_URL)).body parser = Nori.new( :parser=> :rexml) @markers_hash = parser.parse(xml_data)["markers"].first[1] end