Sha256: 486a8834d44c791d9502054fb6a6d0a1efc2216598f3de41b210323c3cf47874

Contents?: true

Size: 414 Bytes

Versions: 1

Compression:

Stored size: 414 Bytes

Contents

# frozen_string_literal: true

module Pull
  class Filter
    def initialize(&block)
      @block = block
    end

    def call(read)
      -> (finish, callback) {
        if finish
          on_abort.()
          return nil
        end

        read.(nil, -> (value) {
          pass = block.call(value)
          callback.(value) if pass
        })
      }
    end

    private

    attr_reader :block
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pull_stream-1.0.0 lib/pull/through/filter.rb