Class: TVdb::Urls

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

Constant Summary collapse

BASE_URL =
"http://www.thetvdb.com"
URLS =
{
  :get_series => "%s/api/GetSeries.php?seriesname={{name}}&language={{language}}",
  :serie_xml => "%s/api/%s/series/{{serie_id}}/{{language}}.xml",
  :serie_full_xml => "%s/api/%s/series/{{serie_id}}/all/{{language}}.xml",
  :serie_banners_xml => "%s/api/%s/series/{{serie_id}}/banners.xml",
  :serie_zip => "%s/api/%s/series/{{serie_id}}/all/{{language}}.zip",
  :episode_xml => "%s/api/%s/episodes/{{episode_id}}/{{language}}.xml"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, base_url = BASE_URL) ⇒ Urls

Returns a new instance of Urls.



15
16
17
18
# File 'lib/tvdb/urls.rb', line 15

def initialize(api_key, base_url=BASE_URL)
  @api_key = api_key
  @templates = URLS.inject({}){|object, (k,v)| object[k] = Template.new(v % [base_url, @api_key]); object}
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



13
14
15
# File 'lib/tvdb/urls.rb', line 13

def api_key
  @api_key
end

#templatesObject (readonly)

Returns the value of attribute templates.



13
14
15
# File 'lib/tvdb/urls.rb', line 13

def templates
  @templates
end

Instance Method Details

#[](key) ⇒ Object



20
21
22
# File 'lib/tvdb/urls.rb', line 20

def [](key)
  @templates[key]
end