Class: SpotifyWebApi::ArtistObject
- Defined in:
- lib/spotify_web_api/models/artist_object.rb
Overview
ArtistObject Model.
Instance Attribute Summary collapse
-
#external_urls ⇒ ExternalUrlObject
Known external URLs for this artist.
-
#followers ⇒ FollowersObject
Information about the followers of the artist.
-
#genres ⇒ Array[String]
A list of the genres the artist is associated with.
-
#href ⇒ String
A link to the Web API endpoint providing full details of the artist.
-
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the artist.
-
#images ⇒ Array[ImageObject]
Images of the artist in various sizes, widest first.
-
#name ⇒ String
The name of the artist.
-
#popularity ⇒ Integer
The popularity of the artist.
-
#type ⇒ TypeEnum
The object type.
-
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the artist.
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(external_urls = SKIP, followers = SKIP, genres = SKIP, href = SKIP, id = SKIP, images = SKIP, name = SKIP, popularity = SKIP, type = SKIP, uri = SKIP) ⇒ ArtistObject
constructor
A new instance of ArtistObject.
Methods inherited from BaseModel
Constructor Details
#initialize(external_urls = SKIP, followers = SKIP, genres = SKIP, href = SKIP, id = SKIP, images = SKIP, name = SKIP, popularity = SKIP, type = SKIP, uri = SKIP) ⇒ ArtistObject
Returns a new instance of ArtistObject.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 94 def initialize(external_urls = SKIP, followers = SKIP, genres = SKIP, href = SKIP, id = SKIP, images = SKIP, name = SKIP, popularity = SKIP, type = SKIP, uri = SKIP) @external_urls = external_urls unless external_urls == SKIP @followers = followers unless followers == SKIP @genres = genres unless genres == SKIP @href = href unless href == SKIP @id = id unless id == SKIP @images = images unless images == SKIP @name = name unless name == SKIP @popularity = popularity unless popularity == SKIP @type = type unless type == SKIP @uri = uri unless uri == SKIP end |
Instance Attribute Details
#external_urls ⇒ ExternalUrlObject
Known external URLs for this artist.
14 15 16 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 14 def external_urls @external_urls end |
#followers ⇒ FollowersObject
Information about the followers of the artist.
18 19 20 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 18 def followers @followers end |
#genres ⇒ Array[String]
A list of the genres the artist is associated with. If not yet classified, the array is empty.
23 24 25 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 23 def genres @genres end |
#href ⇒ String
A link to the Web API endpoint providing full details of the artist.
27 28 29 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 27 def href @href end |
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the artist.
32 33 34 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 32 def id @id end |
#images ⇒ Array[ImageObject]
Images of the artist in various sizes, widest first.
36 37 38 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 36 def images @images end |
#name ⇒ String
The name of the artist.
40 41 42 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 40 def name @name end |
#popularity ⇒ Integer
The popularity of the artist. The value will be between 0 and 100, with 100 being the most popular. The artist’s popularity is calculated from the popularity of all the artist’s tracks.
46 47 48 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 46 def popularity @popularity end |
#type ⇒ TypeEnum
The object type.
50 51 52 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 50 def type @type end |
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the artist.
55 56 57 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 55 def uri @uri end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 110 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls'] followers = FollowersObject.from_hash(hash['followers']) if hash['followers'] genres = hash.key?('genres') ? hash['genres'] : SKIP href = hash.key?('href') ? hash['href'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP # Parameter is an array, so we need to iterate through it images = nil unless hash['images'].nil? images = [] hash['images'].each do |structure| images << (ImageObject.from_hash(structure) if structure) end end images = SKIP unless hash.key?('images') name = hash.key?('name') ? hash['name'] : SKIP popularity = hash.key?('popularity') ? hash['popularity'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP uri = hash.key?('uri') ? hash['uri'] : SKIP # Create object from extracted values. ArtistObject.new(external_urls, followers, genres, href, id, images, name, popularity, type, uri) end |
.names ⇒ Object
A mapping from model property names to API property names.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 58 def self.names @_hash = {} if @_hash.nil? @_hash['external_urls'] = 'external_urls' @_hash['followers'] = 'followers' @_hash['genres'] = 'genres' @_hash['href'] = 'href' @_hash['id'] = 'id' @_hash['images'] = 'images' @_hash['name'] = 'name' @_hash['popularity'] = 'popularity' @_hash['type'] = 'type' @_hash['uri'] = 'uri' @_hash end |
.nullables ⇒ Object
An array for nullable fields
90 91 92 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 90 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/spotify_web_api/models/artist_object.rb', line 74 def self.optionals %w[ external_urls followers genres href id images name popularity type uri ] end |