Sha256: 6fc821ae912c3c806f9efd52b9c4f099c2690a3057eb31b06026bace02945d30

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Pacer::Pipes
  class BlockFilterPipe < AbstractPipe
    field_reader :starts

    def initialize(back, block, invert = false)
      super()
      @back = back
      @block = block
      @graph = back.graph
      @invert = invert

      @exts = @back.extensions + [Pacer::Extensions::BlockFilterElement]
      @is_element = @graph.element_type?(back.element_type) if @graph
    end

    def processNextStart()
      while raw_element = starts.next
        if @is_element
          extended_element = raw_element.add_extensions(@exts)
          extended_element.back = @back
          extended_element.graph = @back.graph
          ok = @block.call extended_element
        else
          ok = @block.call raw_element
        end
        ok = !ok if @invert
        return raw_element if ok
      end
      raise Pacer::NoSuchElementException
    rescue NativeException => e
      if e.cause.getClass == Pacer::NoSuchElementException.getClass
        raise e.cause
      else
        raise e
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pacer-0.9.1.1-java lib/pacer/pipe/block_filter_pipe.rb