Class: TF2R::API

Inherits:
Object
  • Object
show all
Defined in:
lib/tf2r/api.rb

Overview

This class handles interaction with TF2R’s “API”, which is really just an open endpoint located at tf2r.com/job.php, in use all over the site for dynamically updating pages.

Constant Summary collapse

HOST =
'http://tf2r.com'
ENDPOINT =
'/job.php'
MAX_ENTRY_RESPONSE_COUNT =

newentry on a checkraffle job can only return up to 2500 entries. This is a problem for any raffles with a maximum entries greater than 2500.

2500

Class Method Summary collapse

Class Method Details

.raffle_info(link_snippet) ⇒ Array

Queries the API for information about a raffle.

Returns:

  • (Array)

    the API response for the raffle.

    • ended (Boolean) whether the raffle is done.

    • timeleft (Fixnum) seconds remaining.

    • max_entry (Fixnum) maximum number of entries.

    • entry (String) but really a number. This is the ID in TF2R’s db of

      the last entry returned in the response.
      
    • wc (Float) the chance for any one participant to win.

    • cur_entry (Fixnum) current number of entries.

    • started (Boolean) whether the raffle has begun.

    • newentry (Array) contains hashes representing participants in

      chronological order.
      
    • chaten (Array) I have no idea.

    • chatmax (+Fixnum) ¯_(ツ)_/¯



30
31
32
33
34
# File 'lib/tf2r/api.rb', line 30

def self.raffle_info(link_snippet)
  params = {checkraffle: true, rid: link_snippet[1..-1],
            lastentrys: 0, lastchat: 0}
  request(params)['message']
end