Class: Smartfm::Item
Defined Under Namespace
Classes: Cue, Response
Constant Summary
collapse
- ATTRIBUTES =
[:sentences, :responses, :cue, :id, :list, :user]
- READONLY_ATTRIBUTES =
[:sentences, :responses, :cue, :id, :user]
Class Method Summary
collapse
Instance Method Summary
collapse
#like!, #likes, #unlike!
#add_image, #add_sound, #attribution_params
included
Methods inherited from Base
attributes, #attributes
Constructor Details
#initialize(params = {}) ⇒ Item
Returns a new instance of Item.
44
45
46
47
48
49
50
51
52
|
# File 'lib/smartfm/models/item.rb', line 44
def initialize(params = {})
params[:responses] = [params[:response]] if params[:response]
@id = params[:id].to_i
@list = params[:list]
@cue = self.deserialize(params[:cue], :as => Smartfm::Item::Cue)
@responses = self.deserialize(params[:responses], :as => Smartfm::Item::Response)
@sentences = self.deserialize(params[:sentences], :as => Smartfm::Sentence)
@user = self.deserialize(params[:user], :as => Smartfm::User)
end
|
Class Method Details
54
55
56
57
58
59
60
61
62
|
# File 'lib/smartfm/models/item.rb', line 54
def self.(text, params = {})
params[:text] = text
hash = self.rest_client.(params)
if params[:words_only] == false
self.deserialize(hash) || []
else
hash
end
end
|
Instance Method Details
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/smartfm/models/item.rb', line 64
def add_tags(auth, *tags)
post_params = {}
tags.each_with_index do |tag, idx|
if tag.is_a?(String)
post_params["semantic_tags[#{idx}][name]"] = tag
else
post_params["semantic_tags[#{idx}][name]"] = tag[:name]
post_params["semantic_tags[#{idx}][disambiguation]"] = tag[:disambiguation]
end
end
self.rest_client.add_tags(auth, post_params.merge(:id => self.id))
end
|
#rest_client ⇒ Object
12
|
# File 'lib/smartfm/models/item.rb', line 12
def rest_client; self.class.rest_client; end
|