Class: Drum::PlaylistAppleMusic

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

Overview

Apple Music-specific metadata about the playlist.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#editableoptional, Boolean

Returns Whether the playlist is editable.

Returns:

  • (optional, Boolean)

    Whether the playlist is editable



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/drum/model/playlist.rb', line 190

PlaylistAppleMusic = Struct.new(
  :library_id, :global_id,
  :public, :editable, :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 [PlaylistAppleMusic] The parsed metadata
  def self.deserialize(h)
    PlaylistAppleMusic.new(
      library_id: h['library_id'],
      global_id: h['global_id'],
      public: h['public'],
      editable: h['editable'],
      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
    {
      'library_id' => self.library_id,
      'global_id' => self.global_id,
      'public' => self.public,
      'editable' => self.editable,
      'image_url' => self.image_url
    }.compact
  end
end

#global_idoptional, String

Returns The global id of the playlist (implies that it is available through the catalog API).

Returns:

  • (optional, String)

    The global id of the playlist (implies that it is available through the catalog API)



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/drum/model/playlist.rb', line 190

PlaylistAppleMusic = Struct.new(
  :library_id, :global_id,
  :public, :editable, :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 [PlaylistAppleMusic] The parsed metadata
  def self.deserialize(h)
    PlaylistAppleMusic.new(
      library_id: h['library_id'],
      global_id: h['global_id'],
      public: h['public'],
      editable: h['editable'],
      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
    {
      'library_id' => self.library_id,
      'global_id' => self.global_id,
      'public' => self.public,
      'editable' => self.editable,
      'image_url' => self.image_url
    }.compact
  end
end

#image_urloptional, String

Returns The playlist cover image, if present.

Returns:

  • (optional, String)

    The playlist cover image, if present



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/drum/model/playlist.rb', line 190

PlaylistAppleMusic = Struct.new(
  :library_id, :global_id,
  :public, :editable, :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 [PlaylistAppleMusic] The parsed metadata
  def self.deserialize(h)
    PlaylistAppleMusic.new(
      library_id: h['library_id'],
      global_id: h['global_id'],
      public: h['public'],
      editable: h['editable'],
      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
    {
      'library_id' => self.library_id,
      'global_id' => self.global_id,
      'public' => self.public,
      'editable' => self.editable,
      'image_url' => self.image_url
    }.compact
  end
end

#library_idoptional, String

Returns The library-internal id of the playlist.

Returns:

  • (optional, String)

    The library-internal id of the playlist



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/drum/model/playlist.rb', line 190

PlaylistAppleMusic = Struct.new(
  :library_id, :global_id,
  :public, :editable, :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 [PlaylistAppleMusic] The parsed metadata
  def self.deserialize(h)
    PlaylistAppleMusic.new(
      library_id: h['library_id'],
      global_id: h['global_id'],
      public: h['public'],
      editable: h['editable'],
      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
    {
      'library_id' => self.library_id,
      'global_id' => self.global_id,
      'public' => self.public,
      'editable' => self.editable,
      'image_url' => self.image_url
    }.compact
  end
end

#publicoptional, Boolean

Returns Whether the playlist is public.

Returns:

  • (optional, Boolean)

    Whether the playlist is public



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/drum/model/playlist.rb', line 190

PlaylistAppleMusic = Struct.new(
  :library_id, :global_id,
  :public, :editable, :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 [PlaylistAppleMusic] The parsed metadata
  def self.deserialize(h)
    PlaylistAppleMusic.new(
      library_id: h['library_id'],
      global_id: h['global_id'],
      public: h['public'],
      editable: h['editable'],
      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
    {
      'library_id' => self.library_id,
      'global_id' => self.global_id,
      'public' => self.public,
      'editable' => self.editable,
      'image_url' => self.image_url
    }.compact
  end
end

Class Method Details

.deserialize(h) ⇒ PlaylistAppleMusic

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

Parameters:

Returns:



199
200
201
202
203
204
205
206
207
# File 'lib/drum/model/playlist.rb', line 199

def self.deserialize(h)
  PlaylistAppleMusic.new(
    library_id: h['library_id'],
    global_id: h['global_id'],
    public: h['public'],
    editable: h['editable'],
    image_url: h['image_url']
  )
end

Instance Method Details

#serializeHash<String, Object>

Serializes the metadata to a Hash that uses string keys.

Returns:



212
213
214
215
216
217
218
219
220
# File 'lib/drum/model/playlist.rb', line 212

def serialize
  {
    'library_id' => self.library_id,
    'global_id' => self.global_id,
    'public' => self.public,
    'editable' => self.editable,
    'image_url' => self.image_url
  }.compact
end