Class: WeebSh::User

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/weeb/data.rb

Overview

Represents a user for shimakaze

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==

Instance Attribute Details

#accountString (readonly)

Returns the ID of the account from the token.

Returns:

  • (String)

    the ID of the account from the token


195
196
197
# File 'lib/weeb/data.rb', line 195

def 
  @account
end

#available_reputationInteger? (readonly)

Returns the amount to times the user may give reputation.

Returns:

  • (Integer, nil)

    the amount to times the user may give reputation


205
206
207
# File 'lib/weeb/data.rb', line 205

def available_reputation
  @available_reputation
end

#bot_idString (readonly)

Returns the ID of the bot that issues reputation.

Returns:

  • (String)

    the ID of the bot that issues reputation


192
193
194
# File 'lib/weeb/data.rb', line 192

def bot_id
  @bot_id
end

#cooldownArray<Time> (readonly) Also known as: taken_reputation

Returns the last time(s) this user has given reputation to another user.

Returns:

  • (Array<Time>)

    the last time(s) this user has given reputation to another user


198
199
200
# File 'lib/weeb/data.rb', line 198

def cooldown
  @cooldown
end

#given_reputationArray<Time> (readonly)

Returns the last time(s) this user has received reputation from another user.

Returns:

  • (Array<Time>)

    the last time(s) this user has received reputation from another user


202
203
204
# File 'lib/weeb/data.rb', line 202

def given_reputation
  @given_reputation
end

#next_available_reputationArray<Time>? (readonly)

Returns the timestamps referring to the remaining cooldown time until the user can give out reputation from now.

Returns:

  • (Array<Time>, nil)

    the timestamps referring to the remaining cooldown time until the user can give out reputation from now


208
209
210
# File 'lib/weeb/data.rb', line 208

def next_available_reputation
  @next_available_reputation
end

#reputationInteger (readonly) Also known as: rep

Returns the reputation of the user.

Returns:

  • (Integer)

    the reputation of the user


188
189
190
# File 'lib/weeb/data.rb', line 188

def reputation
  @reputation
end

Instance Method Details

#decrease(amount) ⇒ User

Decreases the user's reputation

Parameters:

  • amount (Integer)

    the amount of reputation that will decrease

Returns:

  • (User)

    the class itself


230
231
232
233
234
# File 'lib/weeb/data.rb', line 230

def decrease(amount)
  response = WeebSh::API::Shimakaze.decrease(@interface, @bot_id, @id, amount)
  patch(response['user'])
  self
end

#give(user) ⇒ User

Gives reputation to another user

Returns:

  • (User)

    the class itself


247
248
249
250
251
252
253
# File 'lib/weeb/data.rb', line 247

def give(user)
  user_id = user.resolve_id if user.respond_to?(:resolve_id)
  response = API::Shimakaze.give(@interface, @bot_id, @id, user_id || user)
  patch(response['sourceUser'])
  user.patch(response['targetUser']) if user.is_a?(User)
  self
end

#increase(amount) ⇒ User

Increases the user's reputation

Parameters:

  • amount (Integer)

    the amount of reputation that will increase

Returns:

  • (User)

    the class itself


221
222
223
224
225
# File 'lib/weeb/data.rb', line 221

def increase(amount)
  response = WeebSh::API::Shimakaze.increase(@interface, @bot_id, @id, amount)
  patch(response['user'])
  self
end

#recieve(user) ⇒ User

Recieves reputation to another user

Returns:

  • (User)

    the class itself


258
259
260
261
262
263
264
# File 'lib/weeb/data.rb', line 258

def recieve(user)
  user_id = user.resolve_id if user.respond_to?(:resolve_id)
  response = API::Shimakaze.give(@interface, @bot_id, user_id || user, @id)
  patch(response['targetUser'])
  user.patch(response['sourceUser']) if user.is_a?(User)
  self
end

#resetUser

Resets the user

Returns:

  • (User)

    the class itself


238
239
240
241
242
# File 'lib/weeb/data.rb', line 238

def reset
  response = WeebSh::API::Shimakaze.reset(@interface, @bot_id, @id)
  patch(response['user'])
  self
end