Class: MapLocation
- Inherits:
-
Object
- Object
- MapLocation
- Defined in:
- lib/googlestaticmap.rb
Overview
Container class for a location on the map. Set either a latitude and longitude, or an address
Instance Attribute Summary collapse
-
#address ⇒ Object
String address - can be a full address, city name, zip code, etc.
-
#latitude ⇒ Object
Decimal degrees, positive is north.
-
#longitude ⇒ Object
Decimal degrees, positive is east.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ MapLocation
constructor
A new instance of MapLocation.
- #to_s ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ MapLocation
Returns a new instance of MapLocation.
220 221 222 |
# File 'lib/googlestaticmap.rb', line 220 def initialize(attrs={}) attrs.each {|k,v| self.send("#{k}=".to_sym,v.to_s)} end |
Instance Attribute Details
#address ⇒ Object
String address - can be a full address, city name, zip code, etc. This is ignored if latitude and longitude are set.
218 219 220 |
# File 'lib/googlestaticmap.rb', line 218 def address @address end |
#latitude ⇒ Object
Decimal degrees, positive is north
211 212 213 |
# File 'lib/googlestaticmap.rb', line 211 def latitude @latitude end |
#longitude ⇒ Object
Decimal degrees, positive is east
214 215 216 |
# File 'lib/googlestaticmap.rb', line 214 def longitude @longitude end |
Instance Method Details
#to_s ⇒ Object
224 225 226 227 228 229 230 231 232 |
# File 'lib/googlestaticmap.rb', line 224 def to_s if latitude && longitude "#{CGI.escape(latitude.to_s)},#{CGI.escape(longitude.to_s)}" elsif address CGI.escape(address) else raise Exception.new("Need to set either latitude and longitude, or address") end end |