Class: TheGamesDB::Feed

Inherits:
Object
  • Object
show all
Includes:
SAXMachine
Defined in:
lib/the_games_db/feed.rb

Constant Summary collapse

BaseApiUrl =
"http://thegamesdb.net/api/"
Timeout =

milliseconds

10_000

Class Method Summary collapse

Class Method Details

.api_url(path) ⇒ Object



22
23
24
# File 'lib/the_games_db/feed.rb', line 22

def self.api_url(path)
  BaseApiUrl + path
end

.bad_response!(response) ⇒ Object



26
27
28
# File 'lib/the_games_db/feed.rb', line 26

def self.bad_response!(response)
  raise TheGamesDB::Exception::BadResponse.new(response.curl_error_message)
end

.fetch(path, params = {}) ⇒ Object



15
16
17
18
19
20
# File 'lib/the_games_db/feed.rb', line 15

def self.fetch(path, params={})
  response = Typhoeus::Request.get(api_url(path), :params => params, :timeout => Timeout)

  bad_response!(response) unless response.success?
  response.body
end

.fetch_and_parse(path, params = {}) ⇒ Object



11
12
13
# File 'lib/the_games_db/feed.rb', line 11

def self.fetch_and_parse(path, params={})
  parse fetch(path, params)
end