Class: Dbl::BotSearch
- Inherits:
-
Object
- Object
- Dbl::BotSearch
- Defined in:
- lib/topgg/botSearch.rb
Overview
This class spreads the BotSearch Response body into different methods
Instance Attribute Summary collapse
-
#obj ⇒ Hash
(also: #raw, #data)
readonly
Get raw hash response.
Instance Method Summary collapse
-
#count ⇒ Integer
The number of bots shown in the first page.
-
#first ⇒ Spreader::Bot
The first result.
-
#initialize(obj) ⇒ BotSearch
constructor
Initalizes the BotSearch class.
-
#results ⇒ Array<Spreader::Bot>
Iterates through the results.
-
#size ⇒ Integer
Length of the results.
-
#total ⇒ Integer
The Total number of results.
Constructor Details
#initialize(obj) ⇒ BotSearch
Initalizes the BotSearch class
7 8 9 |
# File 'lib/topgg/botSearch.rb', line 7 def initialize(obj) @obj = obj end |
Instance Attribute Details
#obj ⇒ Hash (readonly) Also known as: raw, data
Get raw hash response
12 13 14 |
# File 'lib/topgg/botSearch.rb', line 12 def obj @obj end |
Instance Method Details
#count ⇒ Integer
The number of bots shown in the first page
32 33 34 |
# File 'lib/topgg/botSearch.rb', line 32 def count @obj['count'].to_i end |
#first ⇒ Spreader::Bot
The first result
26 27 28 |
# File 'lib/topgg/botSearch.rb', line 26 def first Spreader::Bot.new(@obj['results'][0]) end |
#results ⇒ Array<Spreader::Bot>
Iterates through the results
38 39 40 41 42 43 44 45 46 |
# File 'lib/topgg/botSearch.rb', line 38 def results arr = [] flag = 0 # iteration flag @obj['results'].each do |data| arr[flag] = Spreader::Bot.new(data) flag += 1 end arr end |
#size ⇒ Integer
Length of the results.
50 51 52 |
# File 'lib/topgg/botSearch.rb', line 50 def size @obj['results'].length end |
#total ⇒ Integer
The Total number of results
20 21 22 |
# File 'lib/topgg/botSearch.rb', line 20 def total @obj['total'].to_i end |