Class: Votigoto::Show

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

Constant Summary collapse

PROPS =
{
   :string => %w(title episode_title description source_station program_id series_id),
   :int => %w(source_size duration source_channel),
   :custom => %w(capture_date content_url details_url in_progress) 
}

Instance Method Summary collapse

Constructor Details

#initialize(hpricot) ⇒ Show

Returns a new instance of Show.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/votigoto/show.rb', line 7

def initialize(hpricot)
  PROPS[:string].each do |property|
    eval(%Q[
        @#{property} = hpricot.at("details/#{property.gsub(/_/,'')}").inner_text rescue nil
    ])
  end
  PROPS[:int].each do |property|
    eval(%Q[
        @#{property} = hpricot.at("details/#{property.gsub(/_/,'')}").inner_text.to_i rescue nil
    ])
  end
  @capture_date = Time.at(hpricot.at("details/capturedate").inner_text.to_i(16)) rescue nil
  @content_url = hpricot.at("links/content/url").inner_text rescue nil
  @details_url = hpricot.at("links/tivovideodetails/url").inner_text rescue nil
  @in_progress = hpricot.at("details/inprogress").inner_text == "Yes" rescue false
end

Instance Method Details

#to_sObject



28
29
30
31
32
33
34
# File 'lib/votigoto/show.rb', line 28

def to_s
  if self.episode_title.nil?
    return self.title
  else
    return self.title + " - " + self.episode_title
  end
end