Class: Nl::NotificationStream

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
nl/lib/nl/notification.rb

Overview

An unbounded-in-time, single-family view of unsolicited messages.

Instance Method Summary collapse

Constructor Details

#initialize(&receive) ⇒ NotificationStream

Returns a new instance of NotificationStream.



96
97
98
# File 'nl/lib/nl/notification.rb', line 96

def initialize(&receive)
  @receive = receive
end

Instance Method Details

#each ⇒ Object



106
107
108
109
110
# File 'nl/lib/nl/notification.rb', line 106

def each
  return enum_for(__method__) unless block_given?

  loop { yield self.next }
end

#next(timeout: nil) ⇒ Object



100
101
102
# File 'nl/lib/nl/notification.rb', line 100

def next(timeout: nil)
  @receive.call(timeout)
end