Class: IMDB::Data::Episode
- Inherits:
-
Object
- Object
- IMDB::Data::Episode
- Includes:
- REGEXP
- Defined in:
- lib/imdb-html/data/episode.rb
Instance Attribute Summary collapse
-
#h4 ⇒ Object
readonly
Returns the value of attribute h4.
Class Method Summary collapse
Instance Method Summary collapse
- #cast ⇒ Object
- #date ⇒ Object
- #description ⇒ Object
- #episode_number ⇒ Object
-
#initialize(noko_h4) ⇒ Episode
constructor
A new instance of Episode.
- #se ⇒ Object
- #season_number ⇒ Object
- #title ⇒ Object
- #to_h ⇒ Object
- #tt ⇒ Object
Constructor Details
#initialize(noko_h4) ⇒ Episode
Returns a new instance of Episode.
14 15 16 |
# File 'lib/imdb-html/data/episode.rb', line 14 def initialize noko_h4 @h4 = noko_h4 end |
Instance Attribute Details
#h4 ⇒ Object (readonly)
Returns the value of attribute h4.
17 18 19 |
# File 'lib/imdb-html/data/episode.rb', line 17 def h4 @h4 end |
Class Method Details
.parse_params(noko_h4) ⇒ Object
6 7 8 9 10 |
# 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 |
Instance Method Details
#cast ⇒ Object
42 43 44 45 46 47 |
# 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 ⇒ Object
36 37 38 |
# File 'lib/imdb-html/data/episode.rb', line 36 def date Date.parse h4.next_element.text end |
#description ⇒ Object
39 40 41 |
# File 'lib/imdb-html/data/episode.rb', line 39 def description h4.next_element.next_element.next.text end |
#episode_number ⇒ Object
23 24 25 26 |
# File 'lib/imdb-html/data/episode.rb', line 23 def episode_number num = h4.text[ CONTENT::EPISODE ] num ? num.rjust(2,'0') : "??" end |
#se ⇒ Object
27 28 29 |
# File 'lib/imdb-html/data/episode.rb', line 27 def se ["S", season_number, "E", episode_number].join end |
#season_number ⇒ Object
19 20 21 22 |
# File 'lib/imdb-html/data/episode.rb', line 19 def season_number num = h4.text[ CONTENT::SEASON ] num ? num.rjust(2,'0') : "??" end |
#title ⇒ Object
30 31 32 |
# File 'lib/imdb-html/data/episode.rb', line 30 def title h4.at('a').text end |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 |
# 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 |