Class: TvdbParty::Series

Inherits:
Object
  • Object
show all
Defined in:
lib/tvdb_party/series.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, options = {}) ⇒ Series

Returns a new instance of Series.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tvdb_party/series.rb', line 7

def initialize(client, options={})
  @client = client
  @id = options["id"]
  @name = options["SeriesName"]
  @overview = options["Overview"]
  @network = options["Network"]
  @runtime = options["Runtime"]
  @air_time = options['Airs_Time'] if options['Airs_Time']
  @imdb_id = options["IMDB_ID"]
  @content_rating = options["ContentRating"]
  @status = options["Status"]

  if options["Genre"]
    @genres = options["Genre"][1..-1].split("|")
  else
    @genres = []
  end

  if options["Rating"] && options["Rating"].size > 0
    @rating = options["Rating"].to_f
  else
    @rating = 0
  end

  if options["RatingCount"] && options["RatingCount"].size > 0
    @rating_count = options["RatingCount"].to_f
  else
    @rating_count = 0
  end

  begin
    @first_aired = Date.parse(options["FirstAired"])
  rescue
    puts 'invalid date'
  end
end

Instance Attribute Details

#actorsObject

Returns the value of attribute actors.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def actors
  @actors
end

#air_timeObject

Returns the value of attribute air_time.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def air_time
  @air_time
end

#bannersObject

Returns the value of attribute banners.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def banners
  @banners
end

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/tvdb_party/series.rb', line 3

def client
  @client
end

#content_ratingObject

Returns the value of attribute content_rating.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def content_rating
  @content_rating
end

#first_airedObject

Returns the value of attribute first_aired.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def first_aired
  @first_aired
end

#genresObject

Returns the value of attribute genres.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def genres
  @genres
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def id
  @id
end

#imdb_idObject

Returns the value of attribute imdb_id.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def imdb_id
  @imdb_id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def name
  @name
end

#networkObject

Returns the value of attribute network.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def network
  @network
end

#overviewObject

Returns the value of attribute overview.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def overview
  @overview
end

#ratingObject

Returns the value of attribute rating.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def rating
  @rating
end

#rating_countObject

Returns the value of attribute rating_count.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def rating_count
  @rating_count
end

#runtimeObject

Returns the value of attribute runtime.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def runtime
  @runtime
end

#seasonsObject

Returns the value of attribute seasons.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def seasons
  @seasons
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/tvdb_party/series.rb', line 4

def status
  @status
end

Instance Method Details

#episodesObject



76
77
78
# File 'lib/tvdb_party/series.rb', line 76

def episodes
  @episodes ||= client.get_all_episodes(self)
end

#fanart(language) ⇒ Object



52
53
54
# File 'lib/tvdb_party/series.rb', line 52

def fanart(language)
  banners.select{|b| b.banner_type == 'fanart' && b.language == language}
end

#get_episode(season_number, episode_number) ⇒ Object



44
45
46
# File 'lib/tvdb_party/series.rb', line 44

def get_episode(season_number, episode_number)
  client.get_episode(self, season_number, episode_number)
end

#posters(language) ⇒ Object



48
49
50
# File 'lib/tvdb_party/series.rb', line 48

def posters(language)
  banners.select{|b| b.banner_type == 'poster' && b.language == language}
end

#season(season_number) ⇒ Object



84
85
86
# File 'lib/tvdb_party/series.rb', line 84

def season(season_number)
  seasons.detect{|s| s.number == season_number}
end

#season_posters(season_number, language) ⇒ Object



60
61
62
# File 'lib/tvdb_party/series.rb', line 60

def season_posters(season_number, language)
  banners.select{|b| b.banner_type == 'season' && b.banner_type2 == 'season' && b.season == season_number.to_s && b.language == language}
end

#seasonwide_posters(season_number, language) ⇒ Object



64
65
66
# File 'lib/tvdb_party/series.rb', line 64

def seasonwide_posters(season_number, language)
  banners.select{|b| b.banner_type == 'season' && b.banner_type2 == 'seasonwide' && b.season == season_number.to_s && b.language == language}
end

#series_banners(language) ⇒ Object



56
57
58
# File 'lib/tvdb_party/series.rb', line 56

def series_banners(language)
  banners.select{|b| b.banner_type == 'series' && b.language == language}
end