Class: MedPipe::PipelineTask::TsvGenerater
- Inherits:
-
Object
- Object
- MedPipe::PipelineTask::TsvGenerater
- Defined in:
- lib/med_pipe/pipeline_task/tsv_generator.rb
Constant Summary collapse
- TSV_OPTION =
{ col_sep: "\t" }.freeze
Instance Method Summary collapse
Instance Method Details
#call(_context, lines) {|生成したtsvファイル| ... } ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/med_pipe/pipeline_task/tsv_generator.rb', line 10 def call(_context, lines) Tempfile.create do |file| lines.each do |line| # nil に置き換えることで""という文字列が出力されてしまうのを回避 normalized_line = line.map { |v| v == "" ? nil : v } tsv_line = CSV.generate_line(normalized_line, **TSV_OPTION) file.puts(tsv_line) end file.rewind yield(file) end end |