Class: Rubot::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/rubot/classes/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execute, attributes = {}, name:) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
# File 'lib/rubot/classes/event.rb', line 9

def initialize(execute, attributes = {}, name:)
  @name = name
  @attributes = attributes
  @execute = execute
end

Instance Attribute Details

#attributes ⇒ Object (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/rubot/classes/event.rb', line 7

def attributes
  @attributes
end

#execute ⇒ Object (readonly)

Returns the value of attribute execute.



7
8
9
# File 'lib/rubot/classes/event.rb', line 7

def execute
  @execute
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/rubot/classes/event.rb', line 7

def name
  @name
end

Instance Method Details

#run ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rubot/classes/event.rb', line 15

def run
  raise "Unknown event #{@name}" unless Rubot.client.method(@name.to_sym)

  Rubot.client.send(@name) do |event|
    @execute.call(event)
  end
end