class IMDB::Data::Episode
Attributes
h4[R]
Public Class Methods
new(noko_h4)
click to toggle source
# File lib/imdb-html/data/episode.rb, line 14 def initialize noko_h4 @h4 = noko_h4 end
parse_params(noko_h4)
click to toggle source
# File lib/imdb-html/data/episode.rb, line 6 def self.parse_params noko_h4 noko_h4.episodes_h4.map do |h4| self.new(h4).to_h end end
Public Instance Methods
cast()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 42 def cast h4.next_element.next_element.next_element.next_element.cast.map do |elem| credit = IMDB::Data::Credit.new elem {:name => credit.name, :nm => credit.nm.nil? ? 0 : credit.nm.to_i, :roles => credit.roles} end rescue nil end
date()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 36 def date Date.parse h4.next_element.text end
description()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 39 def description h4.next_element.next_element.next.text end
episode_number()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 23 def episode_number num = h4.text[ CONTENT::EPISODE ] num ? num.rjust(2,'0') : "??" end
se()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 27 def se ["S", season_number, "E", episode_number].join end
season_number()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 19 def season_number num = h4.text[ CONTENT::SEASON ] num ? num.rjust(2,'0') : "??" end
title()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 30 def title h4.at('a').text end
to_h()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 48 def to_h hash = {:se => se, :title => title} hash[:tt] = tt.to_i if tt hash[:air_date] = date hash[:description] = description.empty? ? nil : description hash[:cast] = cast hash end
tt()
click to toggle source
# File lib/imdb-html/data/episode.rb, line 33 def tt h4.at('a')["href"][ HTML::TT ] end