Class: DBLRuby

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

Overview

All DBLRuby functionality, whether extended or just here.

Defined Under Namespace

Modules: Errors Classes: Bot, Search, Stats, User, Weekend, Widget

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apikey, id) ⇒ DBLRuby

Initialize a new DBL API, via a key.

Parameters:

  • apikey (String)

    API Key of the bot, taken from the DBL.

  • id (Integer, String)

    Integer/String of the bot's id.


10
11
12
13
# File 'lib/dblruby.rb', line 10

def initialize(apikey, id)
  @api = apikey
  @id = id
end

Instance Attribute Details

#apiObject Also known as: apikey

Get the API Key from instantiation


80
81
82
# File 'lib/dblruby.rb', line 80

def api
  @api
end

#idObject

Get the ID from instantiation


77
78
79
# File 'lib/dblruby.rb', line 77

def id
  @id
end

Instance Method Details

#bot(id) ⇒ Object Also known as: loadbot

Load a bot.

Parameters:

  • id (Integer, String)

    Integer/String ID of the bot you're requesting.


22
23
24
# File 'lib/dblruby.rb', line 22

def bot(id)
  Bot.new(id: id, api: @api)
end

#search(search: nil, limit: 50, offset: 0, sort: nil, fields: nil) ⇒ Object


67
68
69
# File 'lib/dblruby.rb', line 67

def search(search: nil, limit: 50, offset: 0, sort: nil, fields: nil)
  Search.new(search: search, limit: limit, offset: offset, sort: sort, fields: fields)
end

#selfBot

Get all of the bot's stats as if you just called DBL.bot(id)

Returns:

  • (Bot)

    the bot as a bot.


30
31
32
# File 'lib/dblruby.rb', line 30

def self
  bot(@id)
end

#statsObject

Initialize stats


16
17
18
# File 'lib/dblruby.rb', line 16

def stats
  Stats.new(@api, @id)
end

#user(id) ⇒ Object Also known as: loaduser

Load a user

Parameters:

  • id (Integer, String)

    Integer/String ID of the user you're requesting.


36
37
38
# File 'lib/dblruby.rb', line 36

def user(id)
  User.new(id, api)
end

#weekendObject

Define weekend


57
58
59
# File 'lib/dblruby.rb', line 57

def weekend
  Weekend.new
end

#weekend?Boolean

Skip the middleman, let's just see if it's the weekend!

Returns:

  • (Boolean)

62
63
64
# File 'lib/dblruby.rb', line 62

def weekend?
  weekend.weekend?
end

#widget(size: 'large', file_type: 'png', small_type: nil, topcolor: nil, middlecolor: nil, usernamecolor: nil, certifiedcolor: nil, datacolor: nil, labelcolor: nil, highlightcolor: nil, avatarbg: nil, leftcolor: nil, rightcolor: nil, lefttextcolor: nil, righttextcolor: nil, id: @id) ⇒ Object


72
73
74
# File 'lib/dblruby.rb', line 72

def widget(size: 'large', file_type: 'png', small_type: nil, topcolor: nil, middlecolor: nil, usernamecolor: nil, certifiedcolor: nil, datacolor: nil, labelcolor: nil, highlightcolor: nil, avatarbg: nil, leftcolor: nil, rightcolor: nil, lefttextcolor: nil, righttextcolor: nil, id: @id)
  Widget.new(size: size, file_type: file_type, small_type: small_type, topcolor: topcolor, middlecolor: middlecolor, usernamecolor: usernamecolor, certifiedcolor: certifiedcolor, datacolor: datacolor, labelcolor: labelcolor, highlightcolor: highlightcolor, avatarbg: avatarbg, leftcolor: leftcolor, rightcolor: rightcolor, lefttextcolor: lefttextcolor, righttextcolor: righttextcolor, id: id)
end