Class: Drum::Artist
Overview
An artist.
Instance Attribute Summary collapse
- 
  
    
      #id  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The (internal) id of the artist. 
- 
  
    
      #name  ⇒ optional, String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The displayed/formatted name of the artist. 
- 
  
    
      #spotify  ⇒ optional, ArtistSpotify 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Spotify-specific metadata. 
Class Method Summary collapse
- 
  
    
      .deserialize(h)  ⇒ Artist 
    
    
  
  
  
  
  
  
  
  
  
    Parses an artist from a nested Hash that uses string keys. 
Instance Method Summary collapse
- 
  
    
      #serialize  ⇒ Hash<String, Object> 
    
    
  
  
  
  
  
  
  
  
  
    Serializes the artist to a nested Hash that uses string keys. 
Instance Attribute Details
#id ⇒ String
Returns The (internal) id of the artist.
| 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # File 'lib/drum/model/artist.rb', line 10 Artist = Struct.new( :id, :name, :spotify, keyword_init: true ) do # Parses an artist from a nested Hash that uses string keys. # # @param [Hash<String, Object>] h The Hash to be parsed # @return [Artist] The parsed artist def self.deserialize(h) Artist.new( id: h['id'], name: h['name'], spotify: h['spotify'].try { |s| ArtistSpotify.deserialize(s) } ) end # Serializes the artist to a nested Hash that uses string keys. # # @return [Hash<String, Object>] The serialized representation def serialize { 'id' => self.id, 'name' => self.name, 'spotify' => self.spotify&.serialize }.compact end end | 
#name ⇒ optional, String
Returns The displayed/formatted name of the artist.
| 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # File 'lib/drum/model/artist.rb', line 10 Artist = Struct.new( :id, :name, :spotify, keyword_init: true ) do # Parses an artist from a nested Hash that uses string keys. # # @param [Hash<String, Object>] h The Hash to be parsed # @return [Artist] The parsed artist def self.deserialize(h) Artist.new( id: h['id'], name: h['name'], spotify: h['spotify'].try { |s| ArtistSpotify.deserialize(s) } ) end # Serializes the artist to a nested Hash that uses string keys. # # @return [Hash<String, Object>] The serialized representation def serialize { 'id' => self.id, 'name' => self.name, 'spotify' => self.spotify&.serialize }.compact end end | 
#spotify ⇒ optional, ArtistSpotify
Returns Spotify-specific metadata.
| 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # File 'lib/drum/model/artist.rb', line 10 Artist = Struct.new( :id, :name, :spotify, keyword_init: true ) do # Parses an artist from a nested Hash that uses string keys. # # @param [Hash<String, Object>] h The Hash to be parsed # @return [Artist] The parsed artist def self.deserialize(h) Artist.new( id: h['id'], name: h['name'], spotify: h['spotify'].try { |s| ArtistSpotify.deserialize(s) } ) end # Serializes the artist to a nested Hash that uses string keys. # # @return [Hash<String, Object>] The serialized representation def serialize { 'id' => self.id, 'name' => self.name, 'spotify' => self.spotify&.serialize }.compact end end | 
Class Method Details
.deserialize(h) ⇒ Artist
Parses an artist from a nested Hash that uses string keys.
| 20 21 22 23 24 25 26 | # File 'lib/drum/model/artist.rb', line 20 def self.deserialize(h) Artist.new( id: h['id'], name: h['name'], spotify: h['spotify'].try { |s| ArtistSpotify.deserialize(s) } ) end |