Class: Drum::TrackAppleMusic

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

Overview

Apple Music-specific metadata about the track.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#catalog_idoptional, String

Returns The global catalog id of the track.

Returns:

  • (optional, String)

    The global catalog id of the track



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/drum/model/track.rb', line 129

TrackAppleMusic = Struct.new(
  :library_id, :catalog_id,
  :preview_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 [TrackAppleMusic] The parsed metadata
  def self.deserialize(h)
    TrackAppleMusic.new(
      library_id: h['library_id'],
      catalog_id: h['catalog_id'],
      preview_url: h['preview_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,
      'catalog_id' => self.catalog_id,
      'preview_url' => self.preview_url
    }.compact
  end
end

#library_idoptional, String

Returns The library-internal id of the track.

Returns:

  • (optional, String)

    The library-internal id of the track



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/drum/model/track.rb', line 129

TrackAppleMusic = Struct.new(
  :library_id, :catalog_id,
  :preview_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 [TrackAppleMusic] The parsed metadata
  def self.deserialize(h)
    TrackAppleMusic.new(
      library_id: h['library_id'],
      catalog_id: h['catalog_id'],
      preview_url: h['preview_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,
      'catalog_id' => self.catalog_id,
      'preview_url' => self.preview_url
    }.compact
  end
end

#preview_urloptional, String

Returns A short preview of the song audio.

Returns:

  • (optional, String)

    A short preview of the song audio



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/drum/model/track.rb', line 129

TrackAppleMusic = Struct.new(
  :library_id, :catalog_id,
  :preview_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 [TrackAppleMusic] The parsed metadata
  def self.deserialize(h)
    TrackAppleMusic.new(
      library_id: h['library_id'],
      catalog_id: h['catalog_id'],
      preview_url: h['preview_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,
      'catalog_id' => self.catalog_id,
      'preview_url' => self.preview_url
    }.compact
  end
end

Class Method Details

.deserialize(h) ⇒ TrackAppleMusic

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

Parameters:

Returns:



138
139
140
141
142
143
144
# File 'lib/drum/model/track.rb', line 138

def self.deserialize(h)
  TrackAppleMusic.new(
    library_id: h['library_id'],
    catalog_id: h['catalog_id'],
    preview_url: h['preview_url']
  )
end

Instance Method Details

#serializeHash<String, Object>

Serializes the metadata to a Hash that uses string keys.

Returns:



149
150
151
152
153
154
155
# File 'lib/drum/model/track.rb', line 149

def serialize
  {
    'library_id' => self.library_id,
    'catalog_id' => self.catalog_id,
    'preview_url' => self.preview_url
  }.compact
end