class Machiawase::Place
@!attribute [r] address
@return [String] the address.
@!attribute [r] google_map_url
@return [String] the url of Google Map.
@!attribute [rw] lat
@return the latitude.
@!attribute [rw] lon
@return the longitude.
Attributes
address[R]
google_map_url[R]
lat[RW]
lon[RW]
Public Class Methods
configure()
click to toggle source
# File lib/machiawase/place.rb, line 45 def self.configure Geocoder.configure( :language => :ja, :http_proxy => ENV["http_proxy"] ) end
geocode(address)
click to toggle source
@return [Hash] geocode of given address.
# File lib/machiawase/place.rb, line 37 def self.geocode(address) Place.configure lat, lon = Geocoder.coordinates(address) {"lat" => lat, "lon" => lon} rescue => exc p exc end
new(lat, lon)
click to toggle source
# File lib/machiawase/place.rb, line 17 def initialize(lat, lon) @lat = lat @lon = lon @address = nil @google_map_url = "http://maps.google.co.jp/maps?q=#{@lat},#{@lon}&ll=#{@lat},#{@lon}&z=14&t=m&brcurrent=3,0x0:0x0,1" @proxy = Machiawase.parse_proxy(ENV["http_proxy"]) Place.configure end
Public Instance Methods
lat=(val)
click to toggle source
# File lib/machiawase/place.rb, line 26 def lat=(val) @lat = val @address = nil end
lon=(val)
click to toggle source
# File lib/machiawase/place.rb, line 31 def lon=(val) @lon = val @address = nil end
to_h()
click to toggle source
@return [Hash] attributes with Hash format.
# File lib/machiawase/place.rb, line 60 def to_h { "latitude" => @lat, "longitude" => @lon, "address" => address, "google_map" => @google_map_url } end
to_json()
click to toggle source
@return [JSON] attributes with JSON format.
# File lib/machiawase/place.rb, line 70 def to_json JSON.pretty_generate(to_h) end
to_msgpack()
click to toggle source
# File lib/machiawase/place.rb, line 74 def to_msgpack to_h.to_msgpack end