Class: Drum::ArtistSpotify

Inherits:
Struct
  • Object
show all
Defined in:
lib/drum/model/artist.rb

Overview

Spotify-specific metadata about the artist.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idString

Returns The id of the artist on Spotify.

Returns:

  • (String)

    The id of the artist on Spotify



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/drum/model/artist.rb', line 46

ArtistSpotify = Struct.new(
  :id,
  :image_url,
  keyword_init: true
) do
  # Parses spotify metadata from a Hash that uses string keys.
  #
  # @param [Hash<String, Object>] h The Hash to be parsed
  # @return [ArtistSpotify] The parsed metadata
  def self.deserialize(h)
    ArtistSpotify.new(
      id: h['id'],
      image_url: h['image_url']
    )
  end

  # Serializes the metadata to a Hash that uses string keys.
  #
  # @return [Hash<String, Object>] The serialized representation
  def serialize
    {
      'id' => self.id,
      'image_url' => self.image_url
    }.compact
  end
end

#image_urloptional, String

Returns An image of the artist.

Returns:

  • (optional, String)

    An image of the artist



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/drum/model/artist.rb', line 46

ArtistSpotify = Struct.new(
  :id,
  :image_url,
  keyword_init: true
) do
  # Parses spotify metadata from a Hash that uses string keys.
  #
  # @param [Hash<String, Object>] h The Hash to be parsed
  # @return [ArtistSpotify] The parsed metadata
  def self.deserialize(h)
    ArtistSpotify.new(
      id: h['id'],
      image_url: h['image_url']
    )
  end

  # Serializes the metadata to a Hash that uses string keys.
  #
  # @return [Hash<String, Object>] The serialized representation
  def serialize
    {
      'id' => self.id,
      'image_url' => self.image_url
    }.compact
  end
end

Class Method Details

.deserialize(h) ⇒ ArtistSpotify

Parses spotify metadata from a Hash that uses string keys.

Parameters:

Returns:



55
56
57
58
59
60
# File 'lib/drum/model/artist.rb', line 55

def self.deserialize(h)
  ArtistSpotify.new(
    id: h['id'],
    image_url: h['image_url']
  )
end

Instance Method Details

#serializeHash<String, Object>

Serializes the metadata to a Hash that uses string keys.

Returns:



65
66
67
68
69
70
# File 'lib/drum/model/artist.rb', line 65

def serialize
  {
    'id' => self.id,
    'image_url' => self.image_url
  }.compact
end