Class: Twitch::ModerationEvent

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

Overview

Information about a moderation action. The action is determined based on the ‘event_type` field.

Constant Summary collapse

DATE_ATTRIBUTES =

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

%i[event_timestamp].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ModerationEvent

Returns a new instance of ModerationEvent.



23
24
25
26
27
28
29
30
31
# File 'lib/twitch/moderation_event.rb', line 23

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

#event_dataObject (readonly)

A hash containing information about the moderation action.



21
22
23
# File 'lib/twitch/moderation_event.rb', line 21

def event_data
  @event_data
end

#event_timestampObject (readonly)

Time at which the event happened.



17
18
19
# File 'lib/twitch/moderation_event.rb', line 17

def event_timestamp
  @event_timestamp
end

#event_typeObject (readonly)

Event type. The ‘moderation.user` prefix is for user bans and unbans in a channel. The `moderation.moderator` prefix is for addition and removal of moderators in a channel.



15
16
17
# File 'lib/twitch/moderation_event.rb', line 15

def event_type
  @event_type
end

#idObject (readonly)

ID of the moderation event.



11
12
13
# File 'lib/twitch/moderation_event.rb', line 11

def id
  @id
end

#versionObject (readonly)

Version of the endpoint the data was retrieved from.



19
20
21
# File 'lib/twitch/moderation_event.rb', line 19

def version
  @version
end