Class: Nanoc::Core::ChangesStream
- Inherits:
-
Object
- Object
- Nanoc::Core::ChangesStream
- Defined in:
- lib/nanoc/core/changes_stream.rb
Defined Under Namespace
Classes: ChangesListener
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(enum: nil) ⇒ ChangesStream
constructor
A new instance of ChangesStream.
- #map ⇒ Object
- #stop ⇒ Object
- #to_enum ⇒ Object
Constructor Details
#initialize(enum: nil) ⇒ ChangesStream
Returns a new instance of ChangesStream.
28 29 30 31 32 33 34 35 |
# File 'lib/nanoc/core/changes_stream.rb', line 28 def initialize(enum: nil) @enum = enum @enum ||= Enumerator.new do |y| @listener = ChangesListener.new(y) yield(@listener) end.lazy end |
Instance Method Details
#each ⇒ Object
49 50 51 52 |
# File 'lib/nanoc/core/changes_stream.rb', line 49 def each(&) @enum.each(&) nil end |
#map ⇒ Object
41 42 43 |
# File 'lib/nanoc/core/changes_stream.rb', line 41 def map(&) self.class.new(enum: @enum.map(&)) end |
#stop ⇒ Object
37 38 39 |
# File 'lib/nanoc/core/changes_stream.rb', line 37 def stop @listener&.to_stop&.call end |
#to_enum ⇒ Object
45 46 47 |
# File 'lib/nanoc/core/changes_stream.rb', line 45 def to_enum @enum end |