Sha256: 23a8e620fd5c1dac08c56bcb4458d610d319c4785f7c999750d22c27374733af

Contents?: true

Size: 791 Bytes

Versions: 27

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

module Discorb
  #
  # Represents a event.
  # This class shouldn't be instantiated directly.
  # Use {Client#on} instead.
  #
  class Event
    # @return [Proc] the block to be called.
    attr_reader :block
    # @return [Symbol] the event id.
    attr_reader :id
    # @return [Hash] the event discriminator.
    attr_reader :discriminator
    # @return [Boolean] whether the event is once or not.
    attr_reader :once
    alias once? once

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

    #
    # Calls the block associated with the event.
    #
    def call(...)
      @block.call(...)
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
discorb-0.6.0 lib/discorb/event.rb
discorb-0.5.6 lib/discorb/event.rb
discorb-0.5.5 lib/discorb/event.rb
discorb-0.5.4 lib/discorb/event.rb
discorb-0.5.3 lib/discorb/event.rb
discorb-0.5.2 lib/discorb/event.rb
discorb-0.5.1 lib/discorb/event.rb
discorb-0.5.0 lib/discorb/event.rb
discorb-0.4.2 lib/discorb/event.rb
discorb-0.4.1 lib/discorb/event.rb
discorb-0.4.0 lib/discorb/event.rb
discorb-0.3.1 lib/discorb/event.rb
discorb-0.3.0 lib/discorb/event.rb
discorb-0.2.5 lib/discorb/event.rb
discorb-0.2.4 lib/discorb/event.rb
discorb-0.2.3 lib/discorb/event.rb
discorb-0.2.1 lib/discorb/event.rb
discorb-0.2.0 lib/discorb/event.rb
discorb-0.1.0 lib/discorb/event.rb
discorb-0.0.8 lib/discorb/event.rb