Class: SpotifyWebApi::RecommendationsObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::RecommendationsObject
- Defined in:
- lib/spotify_web_api/models/recommendations_object.rb
Overview
RecommendationsObject Model.
Instance Attribute Summary collapse
-
#seeds ⇒ Array[RecommendationSeedObject]
An array of recommendation seed objects.
-
#tracks ⇒ Array[TrackObject]
An array of track objects ordered according to the parameters supplied.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(seeds = nil, tracks = nil) ⇒ RecommendationsObject
constructor
A new instance of RecommendationsObject.
Methods inherited from BaseModel
Constructor Details
#initialize(seeds = nil, tracks = nil) ⇒ RecommendationsObject
Returns a new instance of RecommendationsObject.
38 39 40 41 |
# File 'lib/spotify_web_api/models/recommendations_object.rb', line 38 def initialize(seeds = nil, tracks = nil) @seeds = seeds @tracks = tracks end |
Instance Attribute Details
#seeds ⇒ Array[RecommendationSeedObject]
An array of recommendation seed objects.
14 15 16 |
# File 'lib/spotify_web_api/models/recommendations_object.rb', line 14 def seeds @seeds end |
#tracks ⇒ Array[TrackObject]
An array of track objects ordered according to the parameters supplied.
18 19 20 |
# File 'lib/spotify_web_api/models/recommendations_object.rb', line 18 def tracks @tracks end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
44 45 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 72 |
# File 'lib/spotify_web_api/models/recommendations_object.rb', line 44 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it seeds = nil unless hash['seeds'].nil? seeds = [] hash['seeds'].each do |structure| seeds << (RecommendationSeedObject.from_hash(structure) if structure) end end seeds = nil unless hash.key?('seeds') # Parameter is an array, so we need to iterate through it tracks = nil unless hash['tracks'].nil? tracks = [] hash['tracks'].each do |structure| tracks << (TrackObject.from_hash(structure) if structure) end end tracks = nil unless hash.key?('tracks') # Create object from extracted values. RecommendationsObject.new(seeds, tracks) end |
.names ⇒ Object
A mapping from model property names to API property names.
21 22 23 24 25 26 |
# File 'lib/spotify_web_api/models/recommendations_object.rb', line 21 def self.names @_hash = {} if @_hash.nil? @_hash['seeds'] = 'seeds' @_hash['tracks'] = 'tracks' @_hash end |
.nullables ⇒ Object
An array for nullable fields
34 35 36 |
# File 'lib/spotify_web_api/models/recommendations_object.rb', line 34 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
29 30 31 |
# File 'lib/spotify_web_api/models/recommendations_object.rb', line 29 def self.optionals [] end |