Sha256: aebacfe25a877aca3c00a96a3da76e0870a1df75b067389696f6b7c32249267d

Contents?: true

Size: 813 Bytes

Versions: 8

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  class Step < AnonymousStep
    attr_reader :client

    def initialize(pool, name, *args, previous_step: nil)
      super(name, *args, previous_step: previous_step)
      @pool = pool
    end

    def next
      to_enum.next
    end

    def hasNext # rubocop:disable Naming/MethodName
      to_enum.peek
      true
    rescue StopIteration
      false
    end

    def to_enum
      @to_enum ||= toList.to_enum
    end

    def toList
      @pool.acquire do |client|
        client.write(bytecode)
      end
    end

    def iterate
      @pool.acquire do |client|
        client.write(bytecode(no_return: true))
      end
    end

    private

    def add_step(step_name, args)
      self.class.new(@pool, step_name, *args, previous_step: self)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
grumlin-0.12.5 lib/grumlin/step.rb
grumlin-0.12.4 lib/grumlin/step.rb
grumlin-0.12.3 lib/grumlin/step.rb
grumlin-0.12.2 lib/grumlin/step.rb
grumlin-0.12.1 lib/grumlin/step.rb
grumlin-0.12.0 lib/grumlin/step.rb
grumlin-0.11.0 lib/grumlin/step.rb
grumlin-0.10.1 lib/grumlin/step.rb