Sha256: 906921e9fed295ae11fd9f7ccdb04707303e8883aa1351c21351751b51f2fc6f

Contents?: true

Size: 761 Bytes

Versions: 29

Compression:

Stored size: 761 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 metadata.
    attr_reader :metadata
    # @return [Boolean] whether the event is once or not.
    attr_reader :once
    alias once? once

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

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

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
discorb-0.12.4 lib/discorb/event.rb
discorb-0.12.3 lib/discorb/event.rb
discorb-0.12.2 lib/discorb/event.rb
discorb-0.12.1 lib/discorb/event.rb
discorb-0.12.0 lib/discorb/event.rb
discorb-0.11.4 lib/discorb/event.rb
discorb-0.11.3 lib/discorb/event.rb
discorb-0.11.2 lib/discorb/event.rb
discorb-0.11.1 lib/discorb/event.rb
discorb-0.11.0 lib/discorb/event.rb
discorb-0.10.3 lib/discorb/event.rb
discorb-0.10.2 lib/discorb/event.rb
discorb-0.10.1 lib/discorb/event.rb
discorb-0.10.0 lib/discorb/event.rb
discorb-0.9.6 lib/discorb/event.rb
discorb-0.9.5 lib/discorb/event.rb
discorb-0.9.4 lib/discorb/event.rb
discorb-0.9.3 lib/discorb/event.rb
discorb-0.9.1 lib/discorb/event.rb
discorb-0.9.0 lib/discorb/event.rb