Module: DList::List::Server

Defined in:
lib/dblista/list/server.rb

Overview

Server lists

Class Method Summary collapse

Class Method Details

.allArray

Fetches all servers

Returns:

  • (Array)

    array of raw server data from DList



37
38
39
40
41
# File 'lib/dblista/list/server.rb', line 37

def self.all
  DList._cache(:serversall) do
    DList._get('/servers/list/top/0?limit=1000000')
  end
end

.premium(page = 0, limit = 10) ⇒ Hash

Fetches premium servers

Parameters:

  • page (Integer) (defaults to: 0)

    page

  • limit (Integer) (defaults to: 10)

    limit of servers per page

Returns:

  • (Hash)

    raw data from DList



26
27
28
29
30
31
32
# File 'lib/dblista/list/server.rb', line 26

def self.premium(page = 0, limit = 10)
  DList._page_integer page
  DList._limit_integer limit
  DList._cache("serverspremium#{page}-#{limit}") do
    DList._get("/servers/list/premium/#{page}?limit=#{limit}")
  end
end

.search(query) ⇒ Hash

Server search

Parameters:

  • query (String)

    search query

Returns:

  • (Hash)

    raw data from DList

Raises:



47
48
49
50
51
52
53
# File 'lib/dblista/list/server.rb', line 47

def self.search(query)
  raise DList::Error, DList::Errors::QUERY_NOT_PROVIDED unless query

  DList._cache("serversearch#{query}") do
    DList._get("/servers/search/#{CGI.escape query.to_s}")
  end
end

.top(page = 0, limit = 10) ⇒ Hash

Fetches top servers

Parameters:

  • page (Integer) (defaults to: 0)

    page

  • limit (Integer) (defaults to: 10)

    limit of servers per page

Returns:

  • (Hash)

    raw data from DList



13
14
15
16
17
18
19
# File 'lib/dblista/list/server.rb', line 13

def self.top(page = 0, limit = 10)
  DList._page_integer page
  DList._limit_integer limit
  DList._cache("serverstop#{page}-#{limit}") do
    DList._get("/servers/list/top/#{page}?limit=#{limit}")
  end
end