Class: SpotifyWebApi::CategoryObject
- Defined in:
- lib/spotify_web_api/models/category_object.rb
Overview
CategoryObject Model.
Instance Attribute Summary collapse
-
#href ⇒ String
A link to the Web API endpoint returning full details of the category.
-
#icons ⇒ Array[ImageObject]
The category icon, in various sizes.
-
#id ⇒ String
The [Spotify category ID](/documentation/web-api/concepts/spotify-uris-ids) of the category.
-
#name ⇒ String
The name of the category.
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(href = nil, icons = nil, id = nil, name = nil) ⇒ CategoryObject
constructor
A new instance of CategoryObject.
Methods inherited from BaseModel
Constructor Details
#initialize(href = nil, icons = nil, id = nil, name = nil) ⇒ CategoryObject
Returns a new instance of CategoryObject.
49 50 51 52 53 54 |
# File 'lib/spotify_web_api/models/category_object.rb', line 49 def initialize(href = nil, icons = nil, id = nil, name = nil) @href = href @icons = icons @id = id @name = name end |
Instance Attribute Details
#href ⇒ String
A link to the Web API endpoint returning full details of the category.
14 15 16 |
# File 'lib/spotify_web_api/models/category_object.rb', line 14 def href @href end |
#icons ⇒ Array[ImageObject]
The category icon, in various sizes.
18 19 20 |
# File 'lib/spotify_web_api/models/category_object.rb', line 18 def icons @icons end |
#id ⇒ String
The [Spotify category ID](/documentation/web-api/concepts/spotify-uris-ids) of the category.
23 24 25 |
# File 'lib/spotify_web_api/models/category_object.rb', line 23 def id @id end |
#name ⇒ String
The name of the category.
27 28 29 |
# File 'lib/spotify_web_api/models/category_object.rb', line 27 def name @name end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/spotify_web_api/models/category_object.rb', line 57 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. href = hash.key?('href') ? hash['href'] : nil # Parameter is an array, so we need to iterate through it icons = nil unless hash['icons'].nil? icons = [] hash['icons'].each do |structure| icons << (ImageObject.from_hash(structure) if structure) end end icons = nil unless hash.key?('icons') id = hash.key?('id') ? hash['id'] : nil name = hash.key?('name') ? hash['name'] : nil # Create object from extracted values. CategoryObject.new(href, icons, id, name) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/spotify_web_api/models/category_object.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['href'] = 'href' @_hash['icons'] = 'icons' @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/spotify_web_api/models/category_object.rb', line 45 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 |
# File 'lib/spotify_web_api/models/category_object.rb', line 40 def self.optionals [] end |