Class: Wrapsquare::Place
- Inherits:
-
Object
- Object
- Wrapsquare::Place
- Defined in:
- lib/wrapsquare/place.rb
Instance Method Summary collapse
- #address ⇒ Object
- #city ⇒ Object
- #country ⇒ Object
-
#icon ⇒ Object
return the icon url if exist or return the default icon.
- #id ⇒ Object
-
#initialize(place) ⇒ Place
constructor
A new instance of Place.
- #latitude ⇒ Object
- #longitude ⇒ Object
- #name ⇒ Object
- #postcode ⇒ Object
-
#to_json(*a) ⇒ Object
Serialize object into json.
Constructor Details
#initialize(place) ⇒ Place
Returns a new instance of Place.
6 7 8 |
# File 'lib/wrapsquare/place.rb', line 6 def initialize(place) @place = place end |
Instance Method Details
#address ⇒ Object
34 35 36 |
# File 'lib/wrapsquare/place.rb', line 34 def address @place["location"]["address"] end |
#city ⇒ Object
30 31 32 |
# File 'lib/wrapsquare/place.rb', line 30 def city @place["location"]["city"] end |
#country ⇒ Object
38 39 40 |
# File 'lib/wrapsquare/place.rb', line 38 def country @place["location"]["country"] end |
#icon ⇒ Object
return the icon url if exist or return the default icon
43 44 45 46 47 48 49 |
# File 'lib/wrapsquare/place.rb', line 43 def icon if (@place["categories"][0] != nil) @place["categories"][0]["icon"]["prefix"] + "64" + @place["categories"][0]["icon"]["suffix"] else "https://ss1.4sqi.net/img/categories_v2/building/default_64.png" end end |
#id ⇒ Object
10 11 12 |
# File 'lib/wrapsquare/place.rb', line 10 def id @place["id"] end |
#latitude ⇒ Object
18 19 20 |
# File 'lib/wrapsquare/place.rb', line 18 def latitude @place["location"]["lat"] end |
#longitude ⇒ Object
14 15 16 |
# File 'lib/wrapsquare/place.rb', line 14 def longitude @place["location"]["lng"] end |
#name ⇒ Object
22 23 24 |
# File 'lib/wrapsquare/place.rb', line 22 def name @place["name"] end |
#postcode ⇒ Object
26 27 28 |
# File 'lib/wrapsquare/place.rb', line 26 def postcode @place["location"]["postalCode"] end |
#to_json(*a) ⇒ Object
Serialize object into json
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/wrapsquare/place.rb', line 52 def to_json(*a) { :id => self.id, :longitude => self.longitude, :latitude => self.latitude, :name => self.name, :postcode => self.postcode, :city => self.city, :address => self.address, :country => self.country, :icon => self.icon }.to_json(*a) end |