Class: Iknow::List
Constant Summary
collapse
- ATTRIBUTES =
[:list_id, :title, :description, :link,
:language, :translation_language, :list_type, :transcript, :embed,
:tags, :media_entry, :author, :author_url, :attribution_license_id]
- NOT_WRITABLE_ATTRIBUTES =
[:list_id]
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
attributes, #attributes, deserialize, #deserialize
Constructor Details
#initialize(params = {}) ⇒ List
Returns a new instance of List.
25
26
27
28
29
30
|
# File 'lib/iknow/model/list.rb', line 25
def initialize(params = {})
@list_id = params['id'].to_i if params['id']
@title = params[:title] || params['title']
@description = params[:description] || params['description']
@link = params[:link] || params['link']
end
|
Class Method Details
.create(params = {}) ⇒ Object
20
21
22
23
|
# File 'lib/iknow/model/list.rb', line 20
def self.create(params = {})
new_list = self.new(params)
new_list.save!
end
|
.matching(keyword, params = {}) ⇒ Object
14
15
16
17
18
|
# File 'lib/iknow/model/list.rb', line 14
def self.matching(keyword, params = {})
params[:keyword] = keyword
response = Iknow::RestClient::List.matching(params)
self.deserialize(response) || []
end
|
.recent(params = {}) ⇒ Object
9
10
11
12
|
# File 'lib/iknow/model/list.rb', line 9
def self.recent(params = {})
response = Iknow::RestClient::List.recent(params)
self.deserialize(response) || []
end
|
Instance Method Details
#items(params = {}) ⇒ Object
32
33
34
35
|
# File 'lib/iknow/model/list.rb', line 32
def items(params = {})
response = Iknow::RestClient::List.items(params.merge(:id => self.list_id))
self.deserialize(response, :as => Iknow::Item) || []
end
|
#save ⇒ Object
46
47
48
49
50
51
|
# File 'lib/iknow/model/list.rb', line 46
def save
self.save!
true
rescue
false
end
|
#save! ⇒ Object
42
43
44
|
# File 'lib/iknow/model/list.rb', line 42
def save!
Iknow::RestClient::List.create(self.to_post_data)
end
|
#sentences(params = {}) ⇒ Object
37
38
39
40
|
# File 'lib/iknow/model/list.rb', line 37
def sentences(params = {})
response = Iknow::RestClient::List.sentences(params.merge(:id => self.list_id))
self.deserialize(response, :as => Iknow::Sentence) || []
end
|