Sha256: f87af7ab8ba2aa04be962b63cc3177db04486a81602a1650b3a4fa842bbf50ed

Contents?: true

Size: 452 Bytes

Versions: 4

Compression:

Stored size: 452 Bytes

Contents

# frozen_string_literal: true

class MedPipe::PipelineTask::Counter
  def initialize
    @count = 0
  end

  # @param context [Hash]
  # @param input [Enumerable<Array<Object>>]
  # @yieldparam [Enumerable<Array<Object>>] inputをそのまま流す
  def call(context, input)
    yield input.map { |x| increment(context); x } # rubocop:disable Style/Semicolon
  end

  def increment(context)
    @count += 1
    context[:data_count] = @count
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
med_pipe-0.2.0 lib/med_pipe/pipeline_task/counter.rb
med_pipe-0.1.1 lib/med_pipe/pipeline_task/counter.rb
med_pipe-0.1.0.5 lib/med_pipe/pipeline_task/counter.rb
med_pipe-0.1.0.4 lib/med_pipe/pipeline_task/counter.rb