Class: Drum::TrackSpotify
Overview
Spotify-specific metadata about the track.
Instance Attribute Summary collapse
-
#id ⇒ String
The id of the track on Spotify.
Class Method Summary collapse
-
.deserialize(h) ⇒ TrackSpotify
Parses spotify metadata from a Hash that uses string keys.
Instance Method Summary collapse
-
#serialize ⇒ Hash<String, Object>
Serializes the metadata to a Hash that uses string keys.
Instance Attribute Details
#id ⇒ String
Returns The id of the track on Spotify.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/drum/model/track.rb', line 97 TrackSpotify = Struct.new( :id, 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 [TrackSpotify] The parsed metadata def self.deserialize(h) TrackSpotify.new( id: h['id'] ) end # Serializes the metadata to a Hash that uses string keys. # # @return [Hash<String, Object>] The serialized representation def serialize { 'id' => self.id }.compact end end |
Class Method Details
.deserialize(h) ⇒ TrackSpotify
Parses spotify metadata from a Hash that uses string keys.
105 106 107 108 109 |
# File 'lib/drum/model/track.rb', line 105 def self.deserialize(h) TrackSpotify.new( id: h['id'] ) end |