Class: Drum::AlbumSpotify

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

Overview

Spotify-specific metadata about the album.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idString

Returns The id of the album on Spotify.

Returns:

  • (String)

    The id of the album on Spotify



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/drum/model/album.rb', line 60

AlbumSpotify = 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 [AlbumSpotify] The parsed metadata
  def self.deserialize(h)
    AlbumSpotify.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_urlString

Returns The URL of the album cover art on Spotify.

Returns:

  • (String)

    The URL of the album cover art on Spotify



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/drum/model/album.rb', line 60

AlbumSpotify = 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 [AlbumSpotify] The parsed metadata
  def self.deserialize(h)
    AlbumSpotify.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) ⇒ AlbumSpotify

Parses spotify metadata from a Hash that uses string keys.

Parameters:

Returns:



69
70
71
72
73
74
# File 'lib/drum/model/album.rb', line 69

def self.deserialize(h)
  AlbumSpotify.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:



79
80
81
82
83
84
# File 'lib/drum/model/album.rb', line 79

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