Class: Genius::Referent
Instance Attribute Summary collapse
-
#annotatable ⇒ Object
readonly
Returns the value of attribute annotatable.
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#annotator_id ⇒ Object
readonly
Returns the value of attribute annotator_id.
-
#classification ⇒ Object
readonly
Returns the value of attribute classification.
-
#fragment ⇒ Object
readonly
Returns the value of attribute fragment.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#song_id ⇒ Object
readonly
Returns the value of attribute song_id.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Resource
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Resource
default_headers, default_params, from_hash, handle_response, http_delete, http_get, http_post, http_put, #initialize, resource_name
Constructor Details
This class inherits a constructor from Genius::Resource
Instance Attribute Details
#annotatable ⇒ Object (readonly)
Returns the value of attribute annotatable.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def annotatable @annotatable end |
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def annotations @annotations end |
#annotator_id ⇒ Object (readonly)
Returns the value of attribute annotator_id.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def annotator_id @annotator_id end |
#classification ⇒ Object (readonly)
Returns the value of attribute classification.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def classification @classification end |
#fragment ⇒ Object (readonly)
Returns the value of attribute fragment.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def fragment @fragment end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def id @id end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def range @range end |
#song_id ⇒ Object (readonly)
Returns the value of attribute song_id.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def song_id @song_id end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/genius/referent.rb', line 3 def url @url end |
Class Method Details
.find ⇒ Object
6 7 8 |
# File 'lib/genius/referent.rb', line 6 def self.find(*) raise NotImplementedError, "A Referent cannot be loaded by its ID in the public API" end |
.where(params = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/genius/referent.rb', line 10 def self.where(params = {}) headers = default_headers.merge(params.delete(:headers) || {}) params = default_params.merge(params) response = http_get("/#{resource_name}s/", query: params, headers: headers) response.parsed_response["response"]["referents"].map do |referent| self.from_hash(referent, text_format: params[:text_format]) end end |
Instance Method Details
#parse_resource! ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/genius/referent.rb', line 25 def parse_resource! @url = resource["url"] @annotations = resource["annotations"].map do |annotation| Annotation.from_hash(annotation) end @song_id = resource["song_id"] @annotator_id = resource["annotator_id"] @fragment = resource["fragment"] @range = resource["range"] @classification = resource["classification"] @annotatable = resource["annotatable"] @id = resource["id"] end |
#reload ⇒ Object
21 22 23 |
# File 'lib/genius/referent.rb', line 21 def reload raise NotReloadableError, "A Referent cannot be reloaded" end |