Sha256: 2261932f243626d0cf38e3bfcadd8f27d543ce92c5248b13da53834f71714ed4
Contents?: true
Size: 925 Bytes
Versions: 5
Compression:
Stored size: 925 Bytes
Contents
module RSpotify class Base attr_accessor :external_urls, :href, :id, :type, :uri def self.find(id, type) pluralized_type = "#{type}s" type_class = eval type.capitalize json = RSpotify.get "#{pluralized_type}/#{id}" type_class.new json end def self.search(query, type, limit = 20, offset = 0) pluralized_type = "#{type}s" type_class = eval type.capitalize json = RSpotify.get 'search', params: { q: query, type: type, limit: limit, offset: offset } items = json[pluralized_type]['items'] items.map { |item| type_class.new item } end def initialize(options = {}) @external_urls = options['external_urls'] @href = options['href'] @id = options['id'] @type = options['type'] @uri = options['uri'] end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
rspotify-0.3.1 | lib/rspotify/base.rb |
rspotify-0.3.0 | lib/rspotify/base.rb |
rspotify-0.2.0 | lib/rspotify/base.rb |
rspotify-0.1.0 | lib/rspotify/base.rb |
rspotify-0.1.1 | lib/rspotify/base.rb |