Class: TvMaze::Show

Inherits:
ApiResource show all
Defined in:
lib/tv_maze/models/show.rb

Class Method Summary collapse

Class Method Details

.all(page = 1) ⇒ Object



38
39
40
# File 'lib/tv_maze/models/show.rb', line 38

def self.all(page = 1)
  build_collection(TvMaze::Requester.get("/shows", {page: page}), TvMaze::ShowRepresenter)
end

.alternative_names(id) ⇒ Object

A list of AKA’s (aliases) for a show. An AKA with its country set to null indicates an AKA in the show’s original country. Otherwise, it’s the AKA for that show in the given foreign country.



12
13
14
# File 'lib/tv_maze/models/show.rb', line 12

def self.alternative_names(id)
  TvMaze::AlternativeName.build_collection(TvMaze::Requester.get("shows/#{id}/akas"), TvMaze::AlternativeNameRepresenter)
end

.cast(id) ⇒ Object

A list of main cast for a show. Each cast item is a combination of a person and a character. Items are ordered by importance, which is determined by the total number of appearances of the given character in this show.



7
8
9
# File 'lib/tv_maze/models/show.rb', line 7

def self.cast(id)
 TvMaze::Cast.build_collection(TvMaze::Requester.get("shows/#{id}/cast"), TvMaze::CastRepresenter)
end

.episodes(id, special: false) ⇒ Object



21
22
23
24
# File 'lib/tv_maze/models/show.rb', line 21

def self.episodes(id, special: false)
  params = {specials: special ? 1 : 0}
  TvMaze::Episode.build_collection(TvMaze::Requester.get("shows/#{id}/episodes", params), TvMaze::EpisodeRepresenter)
end

.find(id, embed: []) ⇒ Object



2
3
4
# File 'lib/tv_maze/models/show.rb', line 2

def self.find(id, embed: [])
  build_single_resource(TvMaze::Requester.get("shows/#{id}", {embed: embed}), TvMaze::ShowRepresenter)
end

.find_by_imdb_id(imdb) ⇒ Object



26
27
28
# File 'lib/tv_maze/models/show.rb', line 26

def self.find_by_imdb_id(imdb)
  build_single_resource(TvMaze::Requester.get("lookup/shows", {imdb: imdb}), TvMaze::ShowRepresenter)
end

.find_by_tvdb_id(tvdb) ⇒ Object



34
35
36
# File 'lib/tv_maze/models/show.rb', line 34

def self.find_by_tvdb_id(tvdb)
  build_single_resource(TvMaze::Requester.get("lookup/shows", {thetvdb: tvdb}), TvMaze::ShowRepresenter)
end

.find_by_tvrage_id(tvrage) ⇒ Object



30
31
32
# File 'lib/tv_maze/models/show.rb', line 30

def self.find_by_tvrage_id(tvrage)
  build_single_resource(TvMaze::Requester.get("lookup/shows", {tvrage: tvrage}), TvMaze::ShowRepresenter)
end

.search(q) ⇒ Object



42
43
44
45
# File 'lib/tv_maze/models/show.rb', line 42

def self.search(q)
  result = TvMaze::Requester.get("search/shows", {q: q})
  build_collection(result.map{|show| show['show'] }, TvMaze::ShowRepresenter)
end

.seasons(id) ⇒ Object

A complete list of seasons for the given show. Seasons are returned in ascending order and contain the full information that’s known about them.



17
18
19
# File 'lib/tv_maze/models/show.rb', line 17

def self.seasons(id)
  TvMaze::Season.build_collection(TvMaze::Requester.get("shows/#{id}/seasons"), TvMaze::SeasonRepresenter)
end