Class: ListCordRB::GetBots
- Inherits:
-
Object
- Object
- ListCordRB::GetBots
- Defined in:
- lib/listcordrb/getbots.rb
Overview
Stats and stuff, ya know.
Instance Attribute Summary collapse
-
#data ⇒ Object
(also: #to_s)
readonly
Data in raw json form.
-
#limit ⇒ Object
readonly
The original limit.
-
#page ⇒ Object
readonly
The original page.
-
#query ⇒ Object
readonly
The original query.
-
#sort ⇒ Object
readonly
The original sort method.
Instance Method Summary collapse
-
#first ⇒ Integer
The ID of the first bot.
-
#initialize(query, sort = 'votes', limit = 1, page = 1) ⇒ GetBots
constructor
Initialize the get bots.
-
#next ⇒ Object
Go to the next page of bots.
Constructor Details
#initialize(query, sort = 'votes', limit = 1, page = 1) ⇒ GetBots
Initialize the get bots
8 9 10 11 12 13 14 15 |
# File 'lib/listcordrb/getbots.rb', line 8 def initialize(query, sort = 'votes', limit = 1, page = 1) @query = query @sort = sort @limit = limit @page = page url = "https://listcord.com/api/bots/#{sort}/#{limit}/#{page * limit - 1}" @data = JSON.parse(RestClient.get(url, params: { q: query })) end |
Instance Attribute Details
#data ⇒ Object (readonly) Also known as: to_s
Returns data in raw json form.
18 19 20 |
# File 'lib/listcordrb/getbots.rb', line 18 def data @data end |
#limit ⇒ Object (readonly)
Returns the original limit.
29 30 31 |
# File 'lib/listcordrb/getbots.rb', line 29 def limit @limit end |
#page ⇒ Object (readonly)
Returns the original page.
32 33 34 |
# File 'lib/listcordrb/getbots.rb', line 32 def page @page end |
#query ⇒ Object (readonly)
Returns the original query.
23 24 25 |
# File 'lib/listcordrb/getbots.rb', line 23 def query @query end |
#sort ⇒ Object (readonly)
Returns the original sort method.
26 27 28 |
# File 'lib/listcordrb/getbots.rb', line 26 def sort @sort end |
Instance Method Details
#first ⇒ Integer
Returns the ID of the first bot.
40 41 42 |
# File 'lib/listcordrb/getbots.rb', line 40 def first @data[0].to_i end |
#next ⇒ Object
Go to the next page of bots
35 36 37 |
# File 'lib/listcordrb/getbots.rb', line 35 def next ListCordRB::GetBots.new(@query, @sort, @limit, @page + 1) end |