Class: Whatser::Collection
- Inherits:
-
Resource
show all
- Includes:
- Enumerable
- Defined in:
- lib/whatser/resources/collection.rb
Instance Attribute Summary collapse
Attributes inherited from Resource
#json
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#api_request, api_request, client, convert_data_to_model, from_hash_to_model, set
Constructor Details
#initialize(collection_data = nil) ⇒ Collection
Returns a new instance of Collection.
44
45
46
47
|
# File 'lib/whatser/resources/collection.rb', line 44
def initialize(collection_data=nil)
self.data = collection_data || []
set_city
end
|
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
5
6
7
|
# File 'lib/whatser/resources/collection.rb', line 5
def city
@city
end
|
#city_name ⇒ Object
Returns the value of attribute city_name.
5
6
7
|
# File 'lib/whatser/resources/collection.rb', line 5
def city_name
@city_name
end
|
#data ⇒ Object
Returns the value of attribute data.
5
6
7
|
# File 'lib/whatser/resources/collection.rb', line 5
def data
@data
end
|
Class Method Details
.add(poi_id, opts = {}) ⇒ Object
16
17
18
|
# File 'lib/whatser/resources/collection.rb', line 16
def add(poi_id, opts={})
api_request :post, "/api/poi/#{poi_id}/black/book", {:body => ''}, :model => Whatser::Poi
end
|
.delete(poi_id) ⇒ Object
20
21
22
|
# File 'lib/whatser/resources/collection.rb', line 20
def delete(poi_id)
api_request :delete, "/api/poi/#{poi_id}/black/book", {:body => ''}, :model => Whatser::Poi
end
|
.list(user_id, opts = {}) ⇒ Object
12
13
14
|
# File 'lib/whatser/resources/collection.rb', line 12
def list(user_id, opts={})
collect_api_request :get, "/api/users/#{user_id}/black/book", {:query => opts}
end
|
.mine(opts = {}) ⇒ Object
8
9
10
|
# File 'lib/whatser/resources/collection.rb', line 8
def mine(opts={})
collect_api_request :get, "/api/users/me/black/book", {:query => opts}
end
|
Instance Method Details
#add(poi_id, opts = {}) ⇒ Object
36
37
38
|
# File 'lib/whatser/resources/collection.rb', line 36
def add(poi_id, opts={})
Whatser::Collection.add(poi_id, opts)
end
|
#delete(poi_id) ⇒ Object
40
41
42
|
# File 'lib/whatser/resources/collection.rb', line 40
def delete(poi_id)
Whatser::Collection.delete(poi_id, opts)
end
|
#each(&block) ⇒ Object
49
50
51
|
# File 'lib/whatser/resources/collection.rb', line 49
def each(&block)
(data || []).each(&block)
end
|
#size ⇒ Object
53
54
55
|
# File 'lib/whatser/resources/collection.rb', line 53
def size
(data || []).size
end
|