Class: Hallon::AlbumBrowse
Overview
AlbumBrowse objects are for retrieving additional data from an album that cannot otherwise be acquired. This includes tracks, reviews, copyright information.
Defined Under Namespace
Classes: Copyrights, Tracks
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#album ⇒ Album?
Album this object is browsing.
-
#artist ⇒ Artist?
Artist performing this album.
-
#copyrights ⇒ Copyrights
Enumerator of copyright notices.
-
#initialize(album) ⇒ AlbumBrowse
constructor
Creates an AlbumBrowse instance from an Album or an Album pointer.
-
#loaded? ⇒ Boolean
True if the album browser is loaded.
-
#request_duration ⇒ Rational
Time it took for the albumbrowse request to complete (in seconds).
-
#review ⇒ String
Album review.
-
#status ⇒ Symbol
Album browser error status.
-
#tracks ⇒ Tracks
Enumerator of tracks.
Methods included from Observable::AlbumBrowse
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(album) ⇒ AlbumBrowse
Also Hallon::Album#browse to browse an Album.
Creates an AlbumBrowse instance from an Album or an Album pointer.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hallon/album_browse.rb', line 35 def initialize(album) pointer = album pointer = pointer.pointer if pointer.respond_to?(:pointer) unless pointer.is_a?(Spotify::Album) given = pointer.respond_to?(:type) ? pointer.type : pointer.inspect raise TypeError, "expected album pointer, was given #{given}" end subscribe_for_callbacks do |callback| @pointer = Spotify.albumbrowse_create(session.pointer, pointer, callback, nil) end raise FFI::NullPointerError, "album browsing failed" if @pointer.null? end |
Instance Method Details
#album ⇒ Album?
Returns album this object is browsing.
74 75 76 77 |
# File 'lib/hallon/album_browse.rb', line 74 def album album = Spotify.albumbrowse_album(pointer) Album.from(album) end |
#artist ⇒ Artist?
Returns artist performing this album.
68 69 70 71 |
# File 'lib/hallon/album_browse.rb', line 68 def artist artist = Spotify.albumbrowse_artist(pointer) Artist.from(artist) end |
#copyrights ⇒ Copyrights
Returns enumerator of copyright notices.
88 89 90 |
# File 'lib/hallon/album_browse.rb', line 88 def copyrights Copyrights.new(self) end |
#loaded? ⇒ Boolean
Returns true if the album browser is loaded.
52 53 54 |
# File 'lib/hallon/album_browse.rb', line 52 def loaded? Spotify.albumbrowse_is_loaded(pointer) 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).
81 82 83 84 85 |
# File 'lib/hallon/album_browse.rb', line 81 def request_duration duration = Spotify.albumbrowse_backend_request_duration(pointer) duration = 0 if duration < 0 Rational(duration, 1000) end |
#review ⇒ String
Returns album review.
63 64 65 |
# File 'lib/hallon/album_browse.rb', line 63 def review Spotify.albumbrowse_review(pointer) end |
#status ⇒ Symbol
Returns album browser error status.
58 59 60 |
# File 'lib/hallon/album_browse.rb', line 58 def status Spotify.albumbrowse_error(pointer) end |