Class: Nanoc::Core::ChangesStream

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/core/changes_stream.rb

Defined Under Namespace

Classes: ChangesListener

Instance Method Summary collapse

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

#eachObject



49
50
51
52
# File 'lib/nanoc/core/changes_stream.rb', line 49

def each(&)
  @enum.each(&)
  nil
end

#mapObject



41
42
43
# File 'lib/nanoc/core/changes_stream.rb', line 41

def map(&)
  self.class.new(enum: @enum.map(&))
end

#stopObject



37
38
39
# File 'lib/nanoc/core/changes_stream.rb', line 37

def stop
  @listener&.to_stop&.call
end

#to_enumObject



45
46
47
# File 'lib/nanoc/core/changes_stream.rb', line 45

def to_enum
  @enum
end