Class: Hallon::Artist

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

Overview

Artists in Hallon are the people behind the songs. Methods are defined for retrieving their names and loaded status.

To retrieve more information about an artist, you can #browse it. This will give access to more detailed data such as bio, portraits and more.

Both Albums and Tracks can have more than one artist.

Instance Attribute Summary

Attributes inherited from Base

#pointer

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) ⇒ Artist (private)

Construct an Artist from a link.

Examples:

from a spotify URI


artist = Hallon::Artist.new("spotify:artist:6uSKeCyQEhvPC2NODgiqFE")

from a link


link = Hallon::Link.new("spotify:artist:6uSKeCyQEhvPC2NODgiqFE")
artist = Hallon::Artist.new(link)

Parameters:

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

32
33
34
# File 'lib/hallon/artist.rb', line 32

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

Instance Method Details

#browse(type = :full) ⇒ ArtistBrowse (private)

Browse the Artist, giving you the ability to explore its’ portraits, biography and more.

Parameters:

Returns:


67
68
69
# File 'lib/hallon/artist.rb', line 67

def browse(type = :full)
  ArtistBrowse.new(pointer, type)
end

Returns pointer representation of given link.

Parameters:

Returns:

  • (Spotify::Link)

    pointer representation of given link.


17
# File 'lib/hallon/artist.rb', line 17

from_link :as_artist

#loaded?Boolean (private)

Returns true if the artist is loaded.

Returns:

  • (Boolean)

    true if the artist is loaded.


42
43
44
# File 'lib/hallon/artist.rb', line 42

def loaded?
  Spotify.artist_is_loaded(pointer)
end

#nameString (private)

Returns name of the artist.

Returns:

  • (String)

    name of the artist.


37
38
39
# File 'lib/hallon/artist.rb', line 37

def name
  Spotify.artist_name(pointer)
end

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

Returns artist portrait as an Image.

Parameters:

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

Returns:

  • (Image, nil)

    artist portrait as an Image.

See Also:


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

def portrait(size = :normal)
  portrait = Spotify.artist_portrait(pointer, size)
  Image.from(portrait)
end

Returns artist portrait as a Link.

Parameters:

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

Returns:

  • (Link, nil)

    artist portrait as a Link.

See Also:


57
58
59
60
# File 'lib/hallon/artist.rb', line 57

def portrait_link(size = :normal)
  portrait = Spotify.link_create_from_artist_portrait(pointer, size)
  Link.from(portrait)
end

Returns Link for the current object.

Returns:


18
# File 'lib/hallon/artist.rb', line 18

to_link   :from_artist