Class: DBLRuby::User
- Inherits:
-
Object
- Object
- DBLRuby::User
- Defined in:
- lib/dblruby/user.rb
Overview
Find information about users.
Instance Attribute Summary collapse
-
#data ⇒ Object
(also: #to_s)
readonly
Data in raw json form.
Instance Method Summary collapse
-
#admin? ⇒ true, false
(also: #admin)
The admin status of the user.
-
#avatar ⇒ String
The avatar hash of the user's avatar.
-
#avatar_img ⇒ String
Get's the user's avatar as an img, ready to be used in image linking.
-
#banner ⇒ String
The banner image url of the user.
-
#bio ⇒ String
The bio of the user.
-
#certified? ⇒ true, false
(also: #certified)
The certified status of the user.
-
#color ⇒ String
(also: #colour)
The custom hex color of the user.
-
#defavatar ⇒ String
The cdn hash of the user's avatar if the user has none.
-
#discriminator ⇒ Integer
(also: #discrim, #tag)
The discriminator of the user.
-
#distinct ⇒ String
Returns the user's distinct, which is the Username and Discriminator.
-
#error ⇒ String?
Return the error if there is one, nil otherwise.
-
#error? ⇒ true, false
Return true if there is an error, false otherwise.
-
#github ⇒ String
The github username of the user.
-
#id ⇒ Integer
The id of the user.
-
#initialize(data) ⇒ User
constructor
Initialize the user.
-
#instagram ⇒ String
The instagram username of the user.
-
#mod? ⇒ true, false
(also: #mod)
The mod status of the user.
-
#reddit ⇒ String
The reddit username of the user.
-
#social ⇒ Hash<String, String>
The social usernames of the user.
-
#social? ⇒ true, false
Does the user have any social links? True if so, false if not.
-
#supporter? ⇒ true, false
(also: #supporter)
The supporter status of the user.
-
#twitter ⇒ String
The twitter username of the user.
-
#username ⇒ String
The username of the user.
-
#webmod? ⇒ true, false
(also: #webmod)
The website moderator status of the user.
-
#youtube ⇒ String
The youtube channel id of the user.
Constructor Details
#initialize(data) ⇒ User
Initialize the user
5 6 7 |
# File 'lib/dblruby/user.rb', line 5 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly) Also known as: to_s
Returns data in raw json form.
10 11 12 |
# File 'lib/dblruby/user.rb', line 10 def data @data end |
Instance Method Details
#admin? ⇒ true, false Also known as: admin
The admin status of the user.
169 170 171 |
# File 'lib/dblruby/user.rb', line 169 def admin? @data['admin'] end |
#avatar ⇒ String
The avatar hash of the user's avatar.
61 62 63 |
# File 'lib/dblruby/user.rb', line 61 def avatar @data['avatar'] end |
#avatar_img ⇒ String
Get's the user's avatar as an img, ready to be used in image linking.
67 68 69 |
# File 'lib/dblruby/user.rb', line 67 def avatar_img "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024" end |
#banner ⇒ String
The banner image url of the user
79 80 81 |
# File 'lib/dblruby/user.rb', line 79 def @data['banner'] end |
#bio ⇒ String
The bio of the user.
73 74 75 |
# File 'lib/dblruby/user.rb', line 73 def bio @data['bio'] end |
#certified? ⇒ true, false Also known as: certified
The certified status of the user.
143 144 145 |
# File 'lib/dblruby/user.rb', line 143 def certified? @data['certifiedDev'] end |
#color ⇒ String Also known as: colour
The custom hex color of the user.
127 128 129 |
# File 'lib/dblruby/user.rb', line 127 def color @data['color'] end |
#defavatar ⇒ String
The cdn hash of the user's avatar if the user has none.
55 56 57 |
# File 'lib/dblruby/user.rb', line 55 def defavatar @data['defAvatar'] end |
#discriminator ⇒ Integer Also known as: discrim, tag
The discriminator of the user.
40 41 42 |
# File 'lib/dblruby/user.rb', line 40 def discriminator @data['discriminator'].delete('#') end |
#distinct ⇒ String
Returns the user's distinct, which is the Username and Discriminator.
49 50 51 |
# File 'lib/dblruby/user.rb', line 49 def distinct "#{username}\##{tag}" end |
#error ⇒ String?
Return the error if there is one, nil otherwise.
16 17 18 |
# File 'lib/dblruby/user.rb', line 16 def error @data['error'] end |
#error? ⇒ true, false
Return true if there is an error, false otherwise.
22 23 24 |
# File 'lib/dblruby/user.rb', line 22 def error? !@data['error'].nil? end |
#github ⇒ String
The github username of the user.
121 122 123 |
# File 'lib/dblruby/user.rb', line 121 def github @data['social']['github'] end |
#id ⇒ Integer
The id of the user.
28 29 30 |
# File 'lib/dblruby/user.rb', line 28 def id @data['id'].to_i end |
#instagram ⇒ String
The instagram username of the user.
115 116 117 |
# File 'lib/dblruby/user.rb', line 115 def instagram @data['social']['instagram'] end |
#mod? ⇒ true, false Also known as: mod
The mod status of the user.
153 154 155 |
# File 'lib/dblruby/user.rb', line 153 def mod? @data['mod'] end |
#reddit ⇒ String
The reddit username of the user.
103 104 105 |
# File 'lib/dblruby/user.rb', line 103 def reddit @data['social']['reddit'] end |
#social ⇒ Hash<String, String>
The social usernames of the user.
85 86 87 |
# File 'lib/dblruby/user.rb', line 85 def @data['social'] end |
#social? ⇒ true, false
Does the user have any social links? True if so, false if not.
91 92 93 |
# File 'lib/dblruby/user.rb', line 91 def @data['social'] != {} end |
#supporter? ⇒ true, false Also known as: supporter
The supporter status of the user.
135 136 137 |
# File 'lib/dblruby/user.rb', line 135 def supporter? @data['supporter'] end |
#twitter ⇒ String
The twitter username of the user.
109 110 111 |
# File 'lib/dblruby/user.rb', line 109 def twitter @data['social']['twitter'] end |
#username ⇒ String
The username of the user.
34 35 36 |
# File 'lib/dblruby/user.rb', line 34 def username @data['username'] end |
#webmod? ⇒ true, false Also known as: webmod
The website moderator status of the user.
161 162 163 |
# File 'lib/dblruby/user.rb', line 161 def webmod? @data['webMod'] end |
#youtube ⇒ String
The youtube channel id of the user.
97 98 99 |
# File 'lib/dblruby/user.rb', line 97 def youtube @data['social']['youtube'] end |