Class: Location
- Inherits:
-
Object
- Object
- Location
- Defined in:
- lib/purlocation/location.rb
Constant Summary collapse
- MARKERS_URL =
"http://www.purdue.edu/campus_map/xml/MarkersAll5.xml"
Instance Attribute Summary collapse
-
#abbr ⇒ Object
Returns the value of attribute abbr.
-
#city ⇒ Object
Returns the value of attribute city.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#long ⇒ Object
Returns the value of attribute long.
-
#name ⇒ Object
Returns the value of attribute name.
-
#state ⇒ Object
Returns the value of attribute state.
-
#street_address ⇒ Object
Returns the value of attribute street_address.
-
#zip ⇒ Object
Returns the value of attribute zip.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(abbr) ⇒ Location
constructor
A new instance of Location.
Constructor Details
#initialize(abbr) ⇒ Location
Returns a new instance of Location.
19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |
Instance Attribute Details
#abbr ⇒ Object
Returns the value of attribute abbr.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def abbr @abbr end |
#city ⇒ Object
Returns the value of attribute city.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def city @city end |
#lat ⇒ Object
Returns the value of attribute lat.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def lat @lat end |
#long ⇒ Object
Returns the value of attribute long.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def long @long end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def name @name end |
#state ⇒ Object
Returns the value of attribute state.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def state @state end |
#street_address ⇒ Object
Returns the value of attribute street_address.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def street_address @street_address end |
#zip ⇒ Object
Returns the value of attribute zip.
6 7 8 |
# File 'lib/purlocation/location.rb', line 6 def zip @zip end |
Class Method Details
.markers_hash ⇒ Object
9 10 11 |
# File 'lib/purlocation/location.rb', line 9 def self.markers_hash @markers_hash ||= populate_markers end |
.populate_markers ⇒ Object
13 14 15 16 17 |
# 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 |