Class: RSpotify::Category
Instance Attribute Summary collapse
-
#external_urls ⇒ NilClass
Inexistent for Category.
-
#href ⇒ String
A link to the Spotify Web API endpoint returning full details of the category.
-
#icons ⇒ Array
An array of image objects.
-
#id ⇒ String
The Spotify ID of the category.
-
#name ⇒ String
The name of the category.
-
#type ⇒ NilClass
Inexistent for Category.
-
#uri ⇒ NilClass
Inexistent for Category.
Class Method Summary collapse
-
.find(id, **options) ⇒ Category
Returns Category object with id provided.
-
.list(limit: 20, offset: 0, **options) ⇒ Array<Category>
Get a list of categories used to tag items in Spotify.
-
.search ⇒ Object
Spotify does not support search for categories.
Instance Method Summary collapse
-
#complete! ⇒ Object
See Base#complete!.
-
#initialize(options = {}) ⇒ Category
constructor
A new instance of Category.
-
#playlists(limit: 20, offset: 0, **options) ⇒ Array<Playlist>
Get a list of Spotify playlists tagged with a particular category.
Methods inherited from Base
#embed, #method_missing, #respond_to?
Constructor Details
#initialize(options = {}) ⇒ Category
Returns a new instance of Category.
66 67 68 69 70 71 |
# File 'lib/rspotify/category.rb', line 66 def initialize( = {}) @icons = ['icons'] @name = ['name'] super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RSpotify::Base
Instance Attribute Details
#external_urls ⇒ NilClass
Inexistent for Category.
10 11 12 |
# File 'lib/rspotify/category.rb', line 10 def external_urls @external_urls end |
#href ⇒ String
A link to the Spotify Web API endpoint returning full details of the category.
10 11 12 |
# File 'lib/rspotify/category.rb', line 10 def href @href end |
#icons ⇒ Array
An array of image objects. The category icons, in various sizes.
10 11 12 |
# File 'lib/rspotify/category.rb', line 10 def icons @icons end |
#id ⇒ String
The Spotify ID of the category
10 11 12 |
# File 'lib/rspotify/category.rb', line 10 def id @id end |
#name ⇒ String
The name of the category.
10 11 12 |
# File 'lib/rspotify/category.rb', line 10 def name @name end |
#type ⇒ NilClass
Inexistent for Category.
10 11 12 |
# File 'lib/rspotify/category.rb', line 10 def type @type end |
#uri ⇒ NilClass
Inexistent for Category.
10 11 12 |
# File 'lib/rspotify/category.rb', line 10 def uri @uri end |
Class Method Details
.find(id, **options) ⇒ Category
Returns Category object with id provided
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rspotify/category.rb', line 23 def self.find(id, **) url = "browse/categories/#{id}" url << '?' if .any? .each_with_index do |option, index| url << "#{option[0]}=#{option[1]}" url << '&' unless index == .size-1 end response = RSpotify.get(url) return response if RSpotify.raw_response Category.new response end |
.list(limit: 20, offset: 0, **options) ⇒ Array<Category>
Get a list of categories used to tag items in Spotify
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rspotify/category.rb', line 49 def self.list(limit: 20, offset: 0, **) url = "browse/categories?limit=#{limit}&offset=#{offset}" .each do |option, value| url << "&#{option}=#{value}" end response = RSpotify.get(url) return response if RSpotify.raw_response response['categories']['items'].map { |i| Category.new i } end |
.search ⇒ Object
Spotify does not support search for categories.
61 62 63 64 |
# File 'lib/rspotify/category.rb', line 61 def self.search(*) warn 'Spotify API does not support search for categories' false end |
Instance Method Details
#complete! ⇒ Object
See Base#complete!
74 75 76 |
# File 'lib/rspotify/category.rb', line 74 def complete! initialize RSpotify.get("browse/categories/#{@id}") end |
#playlists(limit: 20, offset: 0, **options) ⇒ Array<Playlist>
Get a list of Spotify playlists tagged with a particular category.
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rspotify/category.rb', line 89 def playlists(limit: 20, offset: 0, **) url = "browse/categories/#{@id}/playlists"\ "?limit=#{limit}&offset=#{offset}" .each do |option, value| url << "&#{option}=#{value}" end response = RSpotify.get(url) return response if RSpotify.raw_response response['playlists']['items'].map { |i| Playlist.new i } end |