Class: Drum::UserSpotify
Overview
Spotify-specific metadata about the user.
Instance Attribute Summary collapse
-
#id ⇒ String
The id of the artist on Spotify.
-
#image_url ⇒ optional, String
The profile image of the user.
Class Method Summary collapse
-
.deserialize(h) ⇒ UserSpotify
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 artist on Spotify.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/drum/model/user.rb', line 46 UserSpotify = Struct.new( :id, :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 [UserSpotify] The parsed user def self.deserialize(h) UserSpotify.new( id: h['id'], 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, 'image_url' => self.image_url }.compact end end |
#image_url ⇒ optional, String
Returns The profile image of the user.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/drum/model/user.rb', line 46 UserSpotify = Struct.new( :id, :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 [UserSpotify] The parsed user def self.deserialize(h) UserSpotify.new( id: h['id'], 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, 'image_url' => self.image_url }.compact end end |
Class Method Details
.deserialize(h) ⇒ UserSpotify
Parses Spotify metadata from a Hash that uses string keys.
55 56 57 58 59 60 |
# File 'lib/drum/model/user.rb', line 55 def self.deserialize(h) UserSpotify.new( id: h['id'], image_url: h['image_url'] ) end |