Class: RubyCord::EventHandler

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

Overview

Represents a event handler. This class shouldn't be instantiated directly. Use Client#on instead.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, id, metadata) ⇒ EventHandler

Returns a new instance of EventHandler.



21
22
23
24
25
26
27
# File 'lib/rubycord/event_handler.rb', line 21

def initialize(block, id, )
  @block = block
  @id = id
  @once = .fetch(:once, false)
   = 
  @rescue = nil
end

Instance Attribute Details

#blockProc (readonly)

Returns the block to be called.

Returns:

  • (Proc)

    the block to be called.



12
13
14
# File 'lib/rubycord/event_handler.rb', line 12

def block
  @block
end

#idSymbol (readonly)

Returns the event id.

Returns:

  • (Symbol)

    the event id.



14
15
16
# File 'lib/rubycord/event_handler.rb', line 14

def id
  @id
end

#metadataHash (readonly)

Returns the event metadata.

Returns:

  • (Hash)

    the event metadata.



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

def 
  
end

#onceBoolean (readonly) Also known as: once?

Returns whether the event is once or not.

Returns:

  • (Boolean)

    whether the event is once or not.



18
19
20
# File 'lib/rubycord/event_handler.rb', line 18

def once
  @once
end

Instance Method Details

#callObject

Calls the block associated with the event.



37
38
39
# File 'lib/rubycord/event_handler.rb', line 37

def call(...)
  @block.call(...)
end

#inspectString

Returns Object class and attributes.

Returns:

  • (String)

    Object class and attributes.



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

def inspect
  "#<#{self.class} @id=#{@id}"
end