Class: Drum::PlaylistSpotify

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

Overview

Spotify-specific metadata about the playlist.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collaborativeoptional, Boolean

Returns Whether the playlist is collaborative on Spotify.

Returns:

  • (optional, Boolean)

    Whether the playlist is collaborative on Spotify



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/drum/model/playlist.rb', line 144

PlaylistSpotify = Struct.new(
  :id,
  :public, :collaborative,
  :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 [PlaylistSpotify] The parsed metadata
  def self.deserialize(h)
    PlaylistSpotify.new(
      id: h['id'],
      public: h['public'],
      collaborative: h['collaborative'],
      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,
      'public' => self.public,
      'collaborative' => self.collaborative,
      'image_url' => self.image_url
    }.compact
  end
end

#idString

Returns The id of the playlist on Spotify.

Returns:

  • (String)

    The id of the playlist on Spotify



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/drum/model/playlist.rb', line 144

PlaylistSpotify = Struct.new(
  :id,
  :public, :collaborative,
  :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 [PlaylistSpotify] The parsed metadata
  def self.deserialize(h)
    PlaylistSpotify.new(
      id: h['id'],
      public: h['public'],
      collaborative: h['collaborative'],
      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,
      'public' => self.public,
      'collaborative' => self.collaborative,
      'image_url' => self.image_url
    }.compact
  end
end

#image_urloptional, String

Returns The playlist cover URL.

Returns:

  • (optional, String)

    The playlist cover URL



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/drum/model/playlist.rb', line 144

PlaylistSpotify = Struct.new(
  :id,
  :public, :collaborative,
  :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 [PlaylistSpotify] The parsed metadata
  def self.deserialize(h)
    PlaylistSpotify.new(
      id: h['id'],
      public: h['public'],
      collaborative: h['collaborative'],
      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,
      'public' => self.public,
      'collaborative' => self.collaborative,
      'image_url' => self.image_url
    }.compact
  end
end

#publicoptional, Boolean

Returns Whether the playlist is public on Spotify.

Returns:

  • (optional, Boolean)

    Whether the playlist is public on Spotify



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/drum/model/playlist.rb', line 144

PlaylistSpotify = Struct.new(
  :id,
  :public, :collaborative,
  :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 [PlaylistSpotify] The parsed metadata
  def self.deserialize(h)
    PlaylistSpotify.new(
      id: h['id'],
      public: h['public'],
      collaborative: h['collaborative'],
      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,
      'public' => self.public,
      'collaborative' => self.collaborative,
      'image_url' => self.image_url
    }.compact
  end
end

Class Method Details

.deserialize(h) ⇒ PlaylistSpotify

Parses spotify metadata from a Hash that uses string keys.

Parameters:

Returns:



154
155
156
157
158
159
160
161
# File 'lib/drum/model/playlist.rb', line 154

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

Instance Method Details

#serializeHash<String, Object>

Serializes the metadata to a Hash that uses string keys.

Returns:



166
167
168
169
170
171
172
173
# File 'lib/drum/model/playlist.rb', line 166

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