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



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

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

Instance Attribute Details

#priorityObject (readonly)

Returns the value of attribute priority



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

def priority
  @priority
end

Instance Method Details

#<<(listener) ⇒ Object



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

def <<(listener)
  listeners << listener
end

#<=>(other) ⇒ Object



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

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

#countObject



57
58
59
# File 'lib/eventception/priority_listeners.rb', line 57

def count
  size
end

#delete(listener) ⇒ Object



45
46
47
# File 'lib/eventception/priority_listeners.rb', line 45

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

#each(&block) ⇒ Object



49
50
51
# File 'lib/eventception/priority_listeners.rb', line 49

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

#empty?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/eventception/priority_listeners.rb', line 61

def empty?
  listeners.empty?
end

#sizeObject



53
54
55
# File 'lib/eventception/priority_listeners.rb', line 53

def size
  listeners.size
end