Class: Sofa::TVRage::Episode

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Mapping
Defined in:
lib/sofa/tvrage/episode.rb

Overview

This class holds the XML information of a single episode as per the TVRage API.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mapping

included

Constructor Details

#initialize(info) ⇒ Episode

Returns a new instance of Episode, mapping info from the TVRage API

Parameters:

  • info (Hash<Symbol, Object>)

    Info to initialize with

Options Hash (info):

  • :epnum (String)

    The episode number in the context of all episodes

  • :seasonnum (String)

    The episode number in the context of its season

  • :prodnum (String)
  • :airdate (String)

    The date the episode airs

  • :link (String)

    The TVRage page for this Episode

  • :title (String)

    The title of this Episode

  • :season_num (String)

    The season number of the Season this Episode belongs to



51
52
53
# File 'lib/sofa/tvrage/episode.rb', line 51

def initialize(info)
  update_with_mapping(info)
end

Instance Attribute Details

#season_numObject (readonly)

The season number of the Season this Episode belongs to. Not actually a part of the TVRage API, but it's used to inject the +season_num+ when looping through Episodes in a Season.



39
40
41
# File 'lib/sofa/tvrage/episode.rb', line 39

def season_num
  @season_num
end

Class Method Details

.info(sid, season_no, ep_num) ⇒ Hash

Gets the info for a Episode.

Parameters:

  • sid (String)

    The show's id

Returns:

  • (Hash)

    The parsed XML

See Also:



19
20
21
22
# File 'lib/sofa/tvrage/episode.rb', line 19

def info(sid, season_no, ep_num)
  xml = get('/feeds/episodeinfo.php', :query => {:sid => sid, :ep => "#{season_no}x#{ep_num}"})
  xml["show"]
end