Class: TheTvdb::Episode

Inherits:
Object
  • Object
show all
Defined in:
lib/the_tvdb/episode.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info) ⇒ Episode

Returns a new instance of Episode.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/the_tvdb/episode.rb', line 8

def initialize(info)
  @remote_id = info['id'].to_i
  @season_remote_id = info['seasonid'].to_i
  @season_number = info['SeasonNumber'].to_i
  @name = info['EpisodeName']
  @number = info['EpisodeNumber'].to_i
  @aired_at = info['FirstAired']
  @description = info['Overview']
  @guest_stars = info['GuestStars'].try(:to_tvdb_array)
  @director = info['Director'].try(:to_tvdb_array)
  @writer = info['Writer'].try(:to_tvdb_array)
  @updated_at = Time.at(info['lastupdated'].to_i)
  @dvd_disc = info['DVD_discid']
  @dvd_season = info['DVD_season']
  @dvd_episode_number = info['DVD_episodenumber']
  @dvd_chapter = info['DVD_chapter']
  @absolute_number = info['absolute_number']
  @image_url = "#{TheTvdb.gateway.mirror}/banners/#{info['filename']}" unless info['filename'].nil?
  @imdb_id = info['IMDB_ID']
  @language = info['Language']
  @prodiction_code = info['ProductionCode']
  @rating = info['Rating'].try(:to_f)
  @rating_count = info['RatingCount'].try(:to_i)
end

Instance Attribute Details

#absolute_numberObject

Returns the value of attribute absolute_number.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def absolute_number
  @absolute_number
end

#aired_atObject

Returns the value of attribute aired_at.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def aired_at
  @aired_at
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def description
  @description
end

#directorObject

Returns the value of attribute director.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def director
  @director
end

#dvd_chapterObject

Returns the value of attribute dvd_chapter.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def dvd_chapter
  @dvd_chapter
end

#dvd_discObject

Returns the value of attribute dvd_disc.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def dvd_disc
  @dvd_disc
end

#dvd_episode_numberObject

Returns the value of attribute dvd_episode_number.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def dvd_episode_number
  @dvd_episode_number
end

#dvd_seasonObject

Returns the value of attribute dvd_season.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def dvd_season
  @dvd_season
end

#guest_starsObject

Returns the value of attribute guest_stars.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def guest_stars
  @guest_stars
end

#image_urlObject

Returns the value of attribute image_url.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def image_url
  @image_url
end

#imdb_idObject

Returns the value of attribute imdb_id.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def imdb_id
  @imdb_id
end

#languageObject

Returns the value of attribute language.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def language
  @language
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def name
  @name
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def number
  @number
end

#production_codeObject

Returns the value of attribute production_code.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def production_code
  @production_code
end

#ratingObject

Returns the value of attribute rating.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def rating
  @rating
end

#rating_countObject

Returns the value of attribute rating_count.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def rating_count
  @rating_count
end

#remote_idObject

Returns the value of attribute remote_id.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def remote_id
  @remote_id
end

#season_numberObject

Returns the value of attribute season_number.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def season_number
  @season_number
end

#season_remote_idObject

Returns the value of attribute season_remote_id.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def season_remote_id
  @season_remote_id
end

#updated_atObject

Returns the value of attribute updated_at.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def updated_at
  @updated_at
end

#writerObject

Returns the value of attribute writer.



4
5
6
# File 'lib/the_tvdb/episode.rb', line 4

def writer
  @writer
end

Class Method Details

.find(remote_id) ⇒ Object



33
34
35
36
# File 'lib/the_tvdb/episode.rb', line 33

def self.find(remote_id)
  info = TheTvdb.gateway.get_episode_details(remote_id)
  self.new(info)
end

Instance Method Details

#to_hashObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/the_tvdb/episode.rb', line 38

def to_hash
  {
    remote_id: @remote_id,
    name: @name,
    description: @description,
    season_remote_id: @season_remote_id,
    season_number: @season_number,
    number: @number,
    aired_at: @aired_at,
    guest_stars: @guest_stars,
    director: @director,
    writer: @writer,
    updated_at: @updated_at,
    dvd_disc: @dvd_disc,
    dvd_season: @dvd_season,
    dvd_episode_number: @dvd_episode_number,
    dvd_chapter: @dvd_chapter,
    absolute_number: @absolute_number,
    image_url: @image_url,
    imdb_id: @imdb_id,
    language: @language,
    production_code: @production_code,
    rating: @rating,
    rating_count: @rating_count
  }
end