Class: SportsSouth::Rotator
- Inherits:
-
Object
- Object
- SportsSouth::Rotator
- Defined in:
- lib/sports_south/rotator.rb
Constant Summary collapse
- API_URL =
'http://tsw-api.com/images/rotator/check.php'
Class Method Summary collapse
Instance Method Summary collapse
- #check(*items) ⇒ Object
-
#initialize(api_user_id, api_key) ⇒ Rotator
constructor
A new instance of Rotator.
Constructor Details
#initialize(api_user_id, api_key) ⇒ Rotator
Returns a new instance of Rotator.
10 11 12 13 |
# File 'lib/sports_south/rotator.rb', line 10 def initialize(api_user_id, api_key) @api_user_id = api_user_id @api_key = api_key end |
Class Method Details
.check(api_user_id, api_key, *items) ⇒ Object
6 7 8 |
# File 'lib/sports_south/rotator.rb', line 6 def self.check(api_user_id, api_key, *items) new(api_user_id, api_key).check(items) end |
Instance Method Details
#check(*items) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sports_south/rotator.rb', line 15 def check(*items) params = { u: @api_user_id, k: @api_key, } params[:i] = items.is_a?(String) ? items.first : items.join(',') uri = URI(API_URL) uri.query = URI.encode_www_form(params) response = Net::HTTP.get_response(uri) results = {} JSON.parse(response.body).each { |k, v| results[k] = v == 'true' } results end |