class GuideboxWrapper::Tv
Attributes
air_day_of_week[R]
air_time[R]
alternative_titles[R]
artwork[R]
backgrounds[RW]
cast[R]
channels[R]
fanart[R]
first_aired[R]
freebase[R]
genres[R]
id[R]
imdb_id[R]
metacritic[R]
network[R]
overview[R]
poster[R]
posters[RW]
rating[R]
runtime[R]
season_total[RW]
seasons[RW]
status[R]
themoviedb[R]
thumbnails[RW]
title[R]
tv_com[R]
tvdb[R]
tvrage[R]
url[R]
wikipedia_id[R]
Public Class Methods
new(show_info)
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 6 def initialize(show_info) excluded_keys = ["common_sense_media", "type", "artwork_208x117", "artwork_304x171", "artwork_448x252", "artwork_608x342"] show_info.each do |key, value| unless excluded_keys.include?(key) instance_variable_set("@#{key}", value) end end @facebook_link = show_info["social"]["facebook"]["link"] @artwork = { "artwork_208x117" => show_info["artwork_208x117"], "artwork_304x171" => show_info["artwork_304x171"], "artwork_448x252" => show_info["artwork_448x252"], "artwork_608x342" => show_info["artwork_608x342"] } end
Public Instance Methods
android_sources()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 59 def android_sources @sources == nil ? "You need to call sources=(api_key) first" : @sources["android"] end
free_sources()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 63 def free_sources if @sources != nil add_sources("free") else "You need to call sources=(api_key) first" end end
images=(api_key)
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 17 def images=(api_key) if @posters == nil wrapper = set_base_url(api_key) url = wrapper.base_url + "/show/" + @id.to_s + "/images/all" images = wrapper.client.query(url)["results"] @posters = images["posters"] @backgrounds = images["backgrounds"] @banners = images["banners"] @thumbnails = images["thumbnails"] end end
ios_sources()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 55 def ios_sources @sources == nil ? "You need to call sources=(api_key) first" : @sources["ios"] end
large_artwork()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 95 def large_artwork @artwork["artwork_448x252"] end
medium_artwork()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 91 def medium_artwork @artwork["artwork_304x171"] end
purchase_sources()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 79 def purchase_sources if @sources != nil add_sources("purchase") else "You need to call sources=(api_key) first" end end
seasons=(api_key)
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 29 def seasons=(api_key) if @seasons == nil wrapper = set_base_url(api_key) url = wrapper.base_url + "/show/" + @id.to_s + "/seasons" results = wrapper.client.query(url) @seasons = results["results"] @season_total = results["total_results"] end end
small_artwork()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 87 def small_artwork @artwork["artwork_208x117"] end
sources=(api_key)
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 39 def sources=(api_key) unless @sources != nil @sources = get_data(api_key, "sources") end end
subscription_sources()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 71 def subscription_sources if @sources != nil add_sources("subscription") else "You need to call sources=(api_key) first" end end
web_sources()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 51 def web_sources @sources == nil ? "You need to call sources=(api_key) first" : @sources["web"] end
xlarge_artwork()
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 99 def xlarge_artwork @artwork["artwork_608x342"] end
Private Instance Methods
add_sources(type)
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 105 def add_sources(type) x = [] web_sources["episodes"]["all_sources"].each { |source| x << (source.merge({ "type" => "web" })) if source["type"] == type } ios_sources["episodes"]["all_sources"].each { |source| x << (source.merge({ "type" => "ios" })) if source["type"] == type } android_sources["episodes"]["all_sources"].each { |source| x << (source.merge({ "type" => "android" })) if source["type"] == type } x end
get_data(api_key, type)
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 118 def get_data(api_key, type) wrapper = set_base_url(api_key) case type when "sources" url = wrapper.base_url + "/show/" + @id.to_s + "/available_content" when "related" url = wrapper.base_url + "/show/" + @id.to_s + "/related" end wrapper.client.query(url)["results"] end
set_base_url(api_key)
click to toggle source
# File lib/GuideboxWrapper/tv/tv.rb, line 113 def set_base_url(api_key) wrapper = GuideboxWrapper::GuideboxTv.new(api_key, "all") wrapper end