Class: Twitch::UserBan

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

Overview

Ban information for a user.

Constant Summary collapse

DATE_ATTRIBUTES =

Fields to be converted from ISO 8601 string to a typed date.

%i[expires_at].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ UserBan

Returns a new instance of UserBan.



16
17
18
19
20
21
22
23
24
# File 'lib/twitch/user_ban.rb', line 16

def initialize(attributes = {})
  attributes.each do |key, value|
    if DATE_ATTRIBUTES.include?(key.to_sym)
      instance_variable_set "@#{key}", Time.parse(value)
    else
      instance_variable_set "@#{key}", value
    end
  end
end

Instance Attribute Details

#expires_atObject (readonly)

Date of when the time-out will expire (nil for permanent bans)



14
15
16
# File 'lib/twitch/user_ban.rb', line 14

def expires_at
  @expires_at
end

#user_idObject (readonly)

ID of the banned/timed-out user.



10
11
12
# File 'lib/twitch/user_ban.rb', line 10

def user_id
  @user_id
end

#user_nameObject (readonly)

Username of the banned/timed-out user.



12
13
14
# File 'lib/twitch/user_ban.rb', line 12

def user_name
  @user_name
end