Class: MedPipe::PipelineTask::Counter
- Inherits:
-
Object
- Object
- MedPipe::PipelineTask::Counter
- Defined in:
- lib/med_pipe/pipeline_task/counter.rb
Instance Method Summary collapse
- #call(context, input) {|inputをそのまま流す| ... } ⇒ Object
- #increment(context) ⇒ Object
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
Constructor Details
#initialize ⇒ Counter
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
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 |