Class: Hallon::ArtistBrowse
Overview
An ArtistBrowse object is for retrieving details about a given artist, such as it’s tracks, albums, similar artists and more.
Defined Under Namespace
Classes: Albums, PortraitLinks, Portraits, SimilarArtists, TopHits, Tracks
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.types ⇒ Array<Symbol>
Artist browsing types for use in #initialize.
Instance Method Summary collapse
-
#albums ⇒ Albums
Artist authored albums.
-
#artist ⇒ Artist?
Artist this browser is browsing.
-
#biography ⇒ String
Artist biography.
-
#initialize(artist, type = :full) ⇒ ArtistBrowse
constructor
Creates an ArtistBrowse instance from an Artist or an Artist pointer.
-
#loaded? ⇒ Boolean
True if the artist browser is loaded.
-
#portrait_links ⇒ PortraitImages
Artist portraits as Links.
-
#portraits ⇒ Portraits
Artist portraits as Images.
-
#request_duration ⇒ Rational
Time it took for the albumbrowse request to complete (in seconds).
-
#similar_artists ⇒ SimilarArtists
Similar artists to this artist.
-
#status ⇒ Symbol
Artist browser error status.
-
#top_hits ⇒ TopHits
Enumerator of the artist’s most popular tracks.
-
#tracks ⇒ Tracks
Artist authored tracks.
Methods included from Observable::ArtistBrowse
extended, initialize_callbacks, load_callback
Methods included from Loadable
Methods inherited from Base
#==, from, from_link, #is_linkable?, #session, to_link, #to_pointer, #to_s
Constructor Details
#initialize(artist, type = :full) ⇒ ArtistBrowse
Also use Hallon::Artist#browse to browse an Artist.
Creates an ArtistBrowse instance from an Artist or an Artist pointer.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/hallon/artist_browse.rb', line 82 def initialize(artist, type = :full) pointer = artist pointer = pointer.pointer if pointer.respond_to?(:pointer) unless pointer.is_a?(Spotify::Artist) given = pointer.respond_to?(:type) ? pointer.type : pointer.inspect raise TypeError, "expected artist pointer, was given #{given}" end subscribe_for_callbacks do |callback| @pointer = Spotify.artistbrowse_create(session.pointer, pointer, type, callback, nil) end raise FFI::NullPointerError, "artist browsing failed" if @pointer.null? end |
Class Method Details
.types ⇒ Array<Symbol>
Returns artist browsing types for use in #initialize.
73 74 75 |
# File 'lib/hallon/artist_browse.rb', line 73 def self.types Spotify.enum_type(:artistbrowse_type).symbols end |
Instance Method Details
#albums ⇒ Albums
Returns artist authored albums.
144 145 146 |
# File 'lib/hallon/artist_browse.rb', line 144 def albums Albums.new(self) end |
#artist ⇒ Artist?
Returns artist this browser is browsing.
110 111 112 113 |
# File 'lib/hallon/artist_browse.rb', line 110 def artist artist = Spotify.artistbrowse_artist(pointer) Artist.from(artist) end |
#biography ⇒ String
Returns artist biography.
116 117 118 |
# File 'lib/hallon/artist_browse.rb', line 116 def biography Spotify.artistbrowse_biography(pointer) end |
#loaded? ⇒ Boolean
Returns true if the artist browser is loaded.
99 100 101 |
# File 'lib/hallon/artist_browse.rb', line 99 def loaded? Spotify.artistbrowse_is_loaded(pointer) end |
#portrait_links ⇒ PortraitImages
Returns artist portraits as Links.
134 135 136 |
# File 'lib/hallon/artist_browse.rb', line 134 def portrait_links PortraitLinks.new(self) end |
#portraits ⇒ Portraits
Returns artist portraits as Images.
129 130 131 |
# File 'lib/hallon/artist_browse.rb', line 129 def portraits Portraits.new(self) end |
#request_duration ⇒ Rational
If the object is not loaded, the result is undefined.
Returns time it took for the albumbrowse request to complete (in seconds).
122 123 124 125 126 |
# File 'lib/hallon/artist_browse.rb', line 122 def request_duration duration = Spotify.artistbrowse_backend_request_duration(pointer) duration = 0 if duration < 0 Rational(duration, 1000) end |
#similar_artists ⇒ SimilarArtists
Returns similar artists to this artist.
149 150 151 |
# File 'lib/hallon/artist_browse.rb', line 149 def similar_artists SimilarArtists.new(self) end |
#status ⇒ Symbol
Returns artist browser error status.
105 106 107 |
# File 'lib/hallon/artist_browse.rb', line 105 def status Spotify.artistbrowse_error(pointer) end |