Class: MedPipe::PipelineTask::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/med_pipe/pipeline_task/counter.rb

Instance Method Summary collapse

Constructor Details

#initializeCounter

Returns a new instance of Counter.



4
5
6
# File 'lib/med_pipe/pipeline_task/counter.rb', line 4

def initialize
  @count = 0
end

Instance Method Details

#call(context, input) {|inputをそのまま流す| ... } ⇒ Object

Parameters:

  • context (Hash)
  • input (Enumerable<Array<Object>>)

Yield Parameters:

  • inputをそのまま流す (Enumerable<Array<Object>>)


11
12
13
# File 'lib/med_pipe/pipeline_task/counter.rb', line 11

def call(context, input)
  yield input.map { |x| increment(context); x } # rubocop:disable Style/Semicolon
end

#increment(context) ⇒ Object



15
16
17
18
# File 'lib/med_pipe/pipeline_task/counter.rb', line 15

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