class Spreader::BotSearch

This class spreads the BotSearch Response body into different methods

Attributes

obj[R]

Get raw hash response @return [Hash]

Public Class Methods

new(obj) click to toggle source

Initalizes the BotSearch class @param obj [Object] Response Hash

# File lib/topgg/botSearch.rb, line 7
def initialize(obj)
  @obj = obj
end

Public Instance Methods

count() click to toggle source

The number of bots shown in the first page @return [Integer]

# File lib/topgg/botSearch.rb, line 28
def count
  @obj['count'].to_i
end
first() click to toggle source

The first result @return [Spreader::Bot]

# File lib/topgg/botSearch.rb, line 22
def first
  Spreader::Bot.new(@obj['results'][0])
end
results() click to toggle source

Iterates through the results @return [Array<Spreader::Bot>]

# File lib/topgg/botSearch.rb, line 34
def results
  arr = []
  flag = 0 # iteration flag
  @obj['results'].each do |data|
    arr[flag] = Spreader::Bot.new(data)
    flag += 1
  end
  arr
end
size() click to toggle source

Length of the results. @return [Integer]

# File lib/topgg/botSearch.rb, line 46
def size
  @obj['results'].length
end
total() click to toggle source

The Total number of results @return [Integer]

# File lib/topgg/botSearch.rb, line 16
def total
  @obj['total'].to_i
end