Class: TheTvDb::Api::Episode

Inherits:
Base::Api::Episode show all
Defined in:
lib/the_tv_db/api/episode.rb

Instance Attribute Summary

Attributes inherited from Base::Api::Episode

#xml_doc

Instance Method Summary collapse

Methods inherited from Base::Api::Episode

#attributes, #initialize, #name, #network_ids, #to_s, #usable?

Methods included from Helpers

#get_remote_file_as_string, #parsable_date?, #safely_parse_date

Constructor Details

This class inherits a constructor from Base::Api::Episode

Instance Method Details

#absolute_numberObject



49
50
51
52
# File 'lib/the_tv_db/api/episode.rb', line 49

def absolute_number
  an = xpath('.//absolute_number')
  an.blank? ? nil : an
end

#air_datesObject



37
38
39
# File 'lib/the_tv_db/api/episode.rb', line 37

def air_dates
  [ Date.parse(xpath('.//FirstAired'))] rescue []
end


41
42
43
44
45
46
47
# File 'lib/the_tv_db/api/episode.rb', line 41

def banner_path
  # See footnotes
  # http://thetvdb.com/wiki/index.php?title=Programmers_API#Episode_Image_Notes
  if (e = xpath('.//EpImgFlag').try(:to_i)) && e <= 2 && i = xpath('.//filename')
    return "#{TheTvDb::Api::Mirrors.all.first}/banners/#{i}" unless i.blank?
  end
end

#network_idObject



5
6
7
# File 'lib/the_tv_db/api/episode.rb', line 5

def network_id
  xpath('.//id').try(:to_i)
end

#numberObject



14
15
16
# File 'lib/the_tv_db/api/episode.rb', line 14

def number
  xpath('.//EpisodeNumber').try(:to_i)
end

#number_of_ratingsObject



33
34
35
# File 'lib/the_tv_db/api/episode.rb', line 33

def number_of_ratings
  xpath('.//RatingCount').try(:to_i)
end

#original_nameObject



22
23
24
# File 'lib/the_tv_db/api/episode.rb', line 22

def original_name
  xpath('.//EpisodeName')
end

#overviewObject



18
19
20
# File 'lib/the_tv_db/api/episode.rb', line 18

def overview
  xpath('.//Overview')
end

#ratingObject



26
27
28
29
30
31
# File 'lib/the_tv_db/api/episode.rb', line 26

def rating
  r = xpath('.//Rating')
  if r.to_f > 0
    return (r.to_f * 10).to_i
  end
end

#season_numberObject



9
10
11
12
# File 'lib/the_tv_db/api/episode.rb', line 9

def season_number
  sn = xpath('.//SeasonNumber').try(:to_i)
  (sn.nil? || sn == 0) ? nil : sn
end