module IOP::Feed

Module to be included into classes which generate and send the data downstream.

@since 0.1

Attributes

downstream[R]

Returns the downstream object or nil if self is the last object in processing pipe.

Public Instance Methods

process(data = nil) click to toggle source

Sends the data block downstream.

@note by convention, the very last call to this method should pass nil to indicate the end-of-data and no data should be sent afterwards.

This implementation simply passes through the received data block downstream if there exists an attached downstream object otherwise the data is simply thrown away.

The overriding method in concrete class which includes {Feed} would normally want to call this one as super after performing specific actions.

# File lib/iop.rb, line 144
def process(data = nil)
  downstream&.process(data) # Ruby 2.3+
end
process!() click to toggle source

Commences the data processing operation.

@abstract

@note this method should be implemented in concrete classes including this module.

Refer to {Sink#process!} for details.

# File lib/iop.rb, line 128
def process!
  raise
end
|(downstream) click to toggle source

Links self and downstream together forming a processing pipe. The subsequent objects may be linked in turn. @return downstream object

# File lib/iop.rb, line 156
def |(downstream)
  downstream.upstream = self
  @downstream = downstream
end