Class: Drum::AlbumAppleMusic

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

Overview

Apple Music-specific metadata about the album.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#image_urloptional, String

Returns The cover image of the album.

Returns:

  • (optional, String)

    The cover image of the album



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/drum/model/album.rb', line 91

AlbumAppleMusic = Struct.new(
  :image_url,
  keyword_init: true
) do
  # Parses Apple Music metadata from a Hash that uses string keys.
  #
  # @param [Hash<String, Object>] h The Hash to be parsed
  # @return [AlbumAppleMusic] The parsed metadata
  def self.deserialize(h)
    AlbumAppleMusic.new(
      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
    {
      'image_url' => self.image_url
    }.compact
  end
end

Class Method Details

.deserialize(h) ⇒ AlbumAppleMusic

Parses Apple Music metadata from a Hash that uses string keys.

Parameters:

Returns:



99
100
101
102
103
# File 'lib/drum/model/album.rb', line 99

def self.deserialize(h)
  AlbumAppleMusic.new(
    image_url: h['image_url']
  )
end

Instance Method Details

#serializeHash<String, Object>

Serializes the metadata to a Hash that uses string keys.

Returns:



108
109
110
111
112
# File 'lib/drum/model/album.rb', line 108

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