Class: Hallon::Album

Inherits:
Base
  • Object
show all
Includes:
Linkable, Loadable
Defined in:
lib/hallon/album.rb

Overview

Note:

Pretty much all methods require the album to be #loaded? to return meaningful results.

Albums are non-detailed metadata about actual music albums.

To retrieve copyrights, album review and tracks you need to browse the album. You do this by calling #browse to retrieve an AlbumBrowse instance.

It does still allow you to query some metadata information, such as its’ #name, #release_year, #type, #artist, #cover

Instance Attribute Summary

Attributes inherited from Base

#pointer

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Loadable

#load

Methods included from Linkable

#===, included, #to_str

Methods inherited from Base

#==, from, from_link, #is_linkable?, #session, to_link, #to_pointer, #to_s

Constructor Details

#initialize(link) ⇒ Album (private)

Construct an Album from a link.

Examples:

from a spotify URI


album = Hallon::Album.new("spotify:album:6TECAywzyJGh0kwxfeBgGc")

from a link


link = Hallon::Link.new("spotify:album:6TECAywzyJGh0kwxfeBgGc")
album = Hallon::Album.new(link)

Parameters:

  • link (String, Link, Spotify::Album)

45
46
47
# File 'lib/hallon/album.rb', line 45

def initialize(link)
  @pointer = to_pointer(link, Spotify::Album)
end

Class Method Details

.typesArray<Symbol>

Returns an array of different kinds of albums (compilations, singles, …)

Examples:


Hallon::Album.types # => [:album, :single, :compilation, :unknown]

Returns:

  • (Array<Symbol>)

    an array of different kinds of albums (compilations, singles, …)


22
23
24
# File 'lib/hallon/album.rb', line 22

def self.types
  Spotify.enum_type(:albumtype).symbols
end

Instance Method Details

#artistArtist? (private)

Returns album artist.

Returns:

  • (Artist, nil)

    album artist.


76
77
78
79
# File 'lib/hallon/album.rb', line 76

def artist
  artist = Spotify.album_artist(pointer)
  Artist.from(artist)
end

#available?Boolean (private)

Returns true if the album is available.

Returns:

  • (Boolean)

    true if the album is available.


66
67
68
# File 'lib/hallon/album.rb', line 66

def available?
  Spotify.album_is_available(pointer)
end

#browseAlbumBrowse (private)

Browse the Album by creating an Hallon::AlbumBrowse instance from it.

Returns:


100
101
102
# File 'lib/hallon/album.rb', line 100

def browse
  AlbumBrowse.new(pointer)
end

#cover(size = :normal) ⇒ Image? (private)

Returns album cover as an Image.

Parameters:

  • size (Symbol) (defaults to: :normal)

Returns:

  • (Image, nil)

    album cover as an Image.

See Also:


84
85
86
87
# File 'lib/hallon/album.rb', line 84

def cover(size = :normal)
  cover = Spotify.album_cover(pointer, size)
  Image.from(cover)
end

Returns album cover as a spotify URI.

Parameters:

  • size (Symbol) (defaults to: :normal)

Returns:

  • (Link, nil)

    album cover as a spotify URI.

See Also:


92
93
94
95
# File 'lib/hallon/album.rb', line 92

def cover_link(size = :normal)
  cover = Spotify.link_create_from_album_cover(pointer, size)
  Link.from(cover)
end

Returns pointer representation of given link.

Parameters:

Returns:

  • (Spotify::Link)

    pointer representation of given link.


31
# File 'lib/hallon/album.rb', line 31

from_link :as_album

#loaded?Boolean (private)

Returns true if the album is loaded.

Returns:

  • (Boolean)

    true if the album is loaded.


71
72
73
# File 'lib/hallon/album.rb', line 71

def loaded?
  Spotify.album_is_loaded(pointer)
end

#nameString (private)

Returns name of the album.

Returns:

  • (String)

    name of the album.


50
51
52
# File 'lib/hallon/album.rb', line 50

def name
  Spotify.album_name(pointer)
end

#release_yearInteger (private)

Returns release year of the album.

Returns:

  • (Integer)

    release year of the album.


55
56
57
# File 'lib/hallon/album.rb', line 55

def release_year
  Spotify.album_year(pointer)
end

Returns Link for the current object.

Returns:


29
# File 'lib/hallon/album.rb', line 29

to_link   :from_album

#typeSymbol (private)

Returns album type.

Returns:

  • (Symbol)

    album type.

See Also:


61
62
63
# File 'lib/hallon/album.rb', line 61

def type
  Spotify.album_type(pointer)
end