Class: TVDB::Client
- Inherits:
-
Object
- Object
- TVDB::Client
- Defined in:
- lib/tvdb-rb/client.rb
Instance Method Summary collapse
- #api_endpoint ⇒ Object
- #get_episode_by_id(episode_id, detailed_response) ⇒ Object
- #get_series_by_id(series_id, detailed_response) ⇒ Object
- #get_series_by_name(query, detailed_response) ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/tvdb-rb/client.rb', line 9 def initialize api_key @api_key = api_key @api_endpoint = "http://www.thetvdb.com/api/#{api_key}" end |
Instance Method Details
#api_endpoint ⇒ Object
34 35 36 |
# File 'lib/tvdb-rb/client.rb', line 34 def api_endpoint @api_endpoint end |
#get_episode_by_id(episode_id, detailed_response) ⇒ Object
19 20 21 22 |
# File 'lib/tvdb-rb/client.rb', line 19 def get_episode_by_id episode_id, detailed_response xml = Nokogiri::XML RestClient.get("#{api_endpoint}/episodes/#{episode_id}") Episode.new(self, series_xml, detailed_response) end |
#get_series_by_id(series_id, detailed_response) ⇒ Object
14 15 16 17 |
# File 'lib/tvdb-rb/client.rb', line 14 def get_series_by_id series_id, detailed_response xml = Nokogiri::XML RestClient.get("#{api_endpoint}/series/#{series_id}") Series.new(self, series_xml, detailed_response) end |
#get_series_by_name(query, detailed_response) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/tvdb-rb/client.rb', line 24 def get_series_by_name query, detailed_response escaped_query = CGI.escape(query) xml = Nokogiri::XML RestClient.get("http://www.thetvdb.com/api/GetSeries.php?seriesname=#{escaped_query}") series = [] xml.xpath("Data/Series").each do |series_xml| series << Series.new(self, series_xml, detailed_response) end series end |