Class: RSpotify::Show
Instance Attribute Summary collapse
-
#available_markets ⇒ Array<String>
A list of the countries in which the show can be played, identified by their ISO 3166-1 alpha-2 code.
-
#copyrights ⇒ Array<Hash>
The copyright statements of the show.
-
#description ⇒ String
A description of the show.
-
#explicit ⇒ Boolean
Whether or not the show has explicit content (true = yes it does; false = no it does not OR unknown).
-
#html_description ⇒ String
A description of the show.
-
#images ⇒ Array<Hash>
The cover art for the show in various sizes, widest first.
-
#is_externally_hosted ⇒ Boolean
True if all of the show’s episodes are hosted outside of Spotify’s CDN.
-
#languages ⇒ Array<String>
A list of the languages used in the show, identified by their ISO 639 code.
-
#media_type ⇒ String
The media type of the show.
-
#name ⇒ String
The name of the show.
-
#publisher ⇒ String
The publisher of the show.
Attributes inherited from Base
#external_urls, #href, #id, #type, #uri
Class Method Summary collapse
-
.find(ids, market: nil) ⇒ Show+
Returns Show object(s) with id(s) provided.
-
.search(query, limit: 20, offset: 0, market: nil) ⇒ Array<Show>
Returns array of Show objects matching the query.
Instance Method Summary collapse
-
#episodes(limit: 20, offset: 0, market: nil) ⇒ Array<Episode>
Returns array of episodes from the show.
-
#initialize(options = {}) ⇒ Show
constructor
A new instance of Show.
Methods inherited from Base
#complete!, #embed, #method_missing, #respond_to?
Constructor Details
#initialize(options = {}) ⇒ Show
Returns a new instance of Show.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rspotify/show.rb', line 47 def initialize( = {}) @available_markets = ['available_markets'] @copyrights = ['copyrights'] @description = ['description'] @explicit = ['explicit'] @html_description = ['html_description'] @images = ['images'] @is_externally_hosted = ['is_externally_hosted'] @languages = ['languages'] @media_type = ['media_type'] @name = ['name'] @publisher = ['publisher'] episodes = ['episodes']['items'] if ['episodes'] @episodes_cache = if episodes episodes.map { |e| Episode.new e } end super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RSpotify::Base
Instance Attribute Details
#available_markets ⇒ Array<String>
A list of the countries in which the show can be played, identified by their ISO 3166-1 alpha-2 code.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def available_markets @available_markets end |
#copyrights ⇒ Array<Hash>
The copyright statements of the show.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def copyrights @copyrights end |
#description ⇒ String
A description of the show. HTML tags are stripped away from this field, use html_description field in case HTML tags are needed.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def description @description end |
#explicit ⇒ Boolean
Whether or not the show has explicit content (true = yes it does; false = no it does not OR unknown).
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def explicit @explicit end |
#html_description ⇒ String
A description of the show. This field may contain HTML tags.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def html_description @html_description end |
#images ⇒ Array<Hash>
The cover art for the show in various sizes, widest first.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def images @images end |
#is_externally_hosted ⇒ Boolean
True if all of the show’s episodes are hosted outside of Spotify’s CDN. This field might be null in some cases.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def is_externally_hosted @is_externally_hosted end |
#languages ⇒ Array<String>
A list of the languages used in the show, identified by their ISO 639 code.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def languages @languages end |
#media_type ⇒ String
The media type of the show.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def media_type @media_type end |
#name ⇒ String
The name of the show.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def name @name end |
#publisher ⇒ String
The publisher of the show.
14 15 16 |
# File 'lib/rspotify/show.rb', line 14 def publisher @publisher end |
Class Method Details
.find(ids, market: nil) ⇒ Show+
Returns Show object(s) with id(s) provided
26 27 28 |
# File 'lib/rspotify/show.rb', line 26 def self.find(ids, market: nil ) super(ids, 'show', market: market) end |
.search(query, limit: 20, offset: 0, market: nil) ⇒ Array<Show>
Returns array of Show objects matching the query. It’s also possible to find the total number of search results for the query
43 44 45 |
# File 'lib/rspotify/show.rb', line 43 def self.search(query, limit: 20, offset: 0, market: nil) super(query, 'show', limit: limit, offset: offset, market: market) end |
Instance Method Details
#episodes(limit: 20, offset: 0, market: nil) ⇒ Array<Episode>
Returns array of episodes from the show
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/rspotify/show.rb', line 79 def episodes(limit: 20, offset: 0, market: nil ) last_episode = offset + limit - 1 if @episodes_cache && last_episode < 20 && !RSpotify.raw_response return @episodes_cache[offset..last_episode] end url = "#{@href}/episodes?limit=#{limit}&offset=#{offset}" url << "&market=#{market}" if market response = RSpotify.get url json = RSpotify.raw_response ? JSON.parse(response) : response episodes = json['items'] episodes.map! { |e| Episode.new e } @episodes_cache = episodes if limit == 20 && offset == 0 return response if RSpotify.raw_response episodes end |