class Genius::Referent

Attributes

annotatable[R]
annotations[R]
annotator_id[R]
classification[R]
fragment[R]
id[R]
range[R]
song_id[R]
url[R]

Public Class Methods

find(*) click to toggle source
# 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 = {}) click to toggle source
# 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

Public Instance Methods

parse_resource!() click to toggle source
# 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() click to toggle source
# File lib/genius/referent.rb, line 21
def reload
  raise NotReloadableError, "A Referent cannot be reloaded"
end
song() click to toggle source
# File lib/genius/referent.rb, line 41
def song
  return nil unless song_id
  Song.find(song_id)
end