Class: Wrapsquare::Place

Inherits:
Object
  • Object
show all
Defined in:
lib/wrapsquare/place.rb

Instance Method Summary collapse

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

#addressObject



34
35
36
# File 'lib/wrapsquare/place.rb', line 34

def address
  @place["location"]["address"]
end

#cityObject



30
31
32
# File 'lib/wrapsquare/place.rb', line 30

def city
  @place["location"]["city"]
end

#countryObject



38
39
40
# File 'lib/wrapsquare/place.rb', line 38

def country
  @place["location"]["country"]
end

#iconObject

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

#idObject



10
11
12
# File 'lib/wrapsquare/place.rb', line 10

def id
  @place["id"]
end

#latitudeObject



18
19
20
# File 'lib/wrapsquare/place.rb', line 18

def latitude
  @place["location"]["lat"]
end

#longitudeObject



14
15
16
# File 'lib/wrapsquare/place.rb', line 14

def longitude
  @place["location"]["lng"]
end

#nameObject



22
23
24
# File 'lib/wrapsquare/place.rb', line 22

def name
  @place["name"]
end

#postcodeObject



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