Class: Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil?, , data = {}) ⇒ Event

Returns a new instance of Event.

Parameters:

  • format (String)

    The name of the event

  • data (Hash) (defaults to: {})

    An Hash containing the data that will be passed to the listeners



9
10
11
12
# File 'lib/gimuby/event/event.rb', line 9

def initialize(name = nil?, data = {})
  @name = name
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



15
16
17
# File 'lib/gimuby/event/event.rb', line 15

def data
  @data
end

#nameObject

Returns the value of attribute name.



14
15
16
# File 'lib/gimuby/event/event.rb', line 14

def name
  @name
end

Instance Method Details

#triggerObject

Trigger the event (through the event manager)



19
20
21
22
# File 'lib/gimuby/event/event.rb', line 19

def trigger
  event_manager = get_event_manager
  event_manager.trigger_event(name, self)
end