Class: Syndi::Events::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/syndi/events.rb

Overview

A class which represents a listener.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sys, event, priority, prc) ⇒ Listener

Spawn a new listener object.



100
101
102
103
104
105
106
107
# File 'lib/syndi/events.rb', line 100

def initialize sys, event, priority, prc
  @sys      = sys
  @event    = event
  @priority = priority
  @code     = prc

  Syndi.log.verbose "new listener spawned and attached to #{event}: #{self}", VNOISY
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



97
98
99
# File 'lib/syndi/events.rb', line 97

def code
  @code
end

#eventObject (readonly)

Returns the value of attribute event.



97
98
99
# File 'lib/syndi/events.rb', line 97

def event
  @event
end

#priorityObject (readonly)

Returns the value of attribute priority.



97
98
99
# File 'lib/syndi/events.rb', line 97

def priority
  @priority
end

Instance Method Details

#call(*args) ⇒ Object

Execute this listener.



115
116
117
# File 'lib/syndi/events.rb', line 115

def call *args
  @code.call *args
end

#deafObject

Terminate this object.



110
111
112
# File 'lib/syndi/events.rb', line 110

def deaf
  @sys.events[event].delete self
end

#inspectObject Also known as: to_s



119
120
121
# File 'lib/syndi/events.rb', line 119

def inspect
  "<#Syndi::Events::Listener: sys=#@sys event=#@event priority=#@priority>"
end