Class: Eventception::PriorityListeners

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/eventception/priority_listeners.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(priority:) ⇒ PriorityListeners

Returns a new instance of PriorityListeners.



13
14
15
16
# File 'lib/eventception/priority_listeners.rb', line 13

def initialize(priority:)
  @priority = priority
  @listeners = []
end

Instance Attribute Details

#priorityObject (readonly)

Returns the value of attribute priority.



11
12
13
# File 'lib/eventception/priority_listeners.rb', line 11

def priority
  @priority
end

Instance Method Details

#<<(listener) ⇒ Object



18
19
20
# File 'lib/eventception/priority_listeners.rb', line 18

def <<(listener)
  listeners << listener
end

#<=>(other) ⇒ Object



22
23
24
# File 'lib/eventception/priority_listeners.rb', line 22

def <=>(other)
  other.priority <=> priority
end

#countObject



38
39
40
# File 'lib/eventception/priority_listeners.rb', line 38

def count
  size
end

#delete(listener) ⇒ Object



26
27
28
# File 'lib/eventception/priority_listeners.rb', line 26

def delete(listener)
  listeners.delete(listener)
end

#each(&block) ⇒ Object



30
31
32
# File 'lib/eventception/priority_listeners.rb', line 30

def each(&block)
  listeners.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/eventception/priority_listeners.rb', line 42

def empty?
  listeners.empty?
end

#sizeObject



34
35
36
# File 'lib/eventception/priority_listeners.rb', line 34

def size
  listeners.size
end