Sha256: 692eeeb34f80d48968dbc37d56ed159cd1efef6db9881ebb5a0ae2120b2b53fc
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
module RocketJob module Batch # Format output results. # # Takes Batch::Results, Batch::Result, Hash, Array, or String and renders it for output. # # Example: # # tabular = Tabular.new( # main: IOStreams::Tabular.new(columns: main_file_headers, format: tabular_output_format), # exceptions: IOStreams::Tabular.new(columns: exception_file_headers, format: tabular_output_format) # ) # # tabular.render(row) # # @deprecated class Tabular autoload :Input, "rocket_job/batch/tabular/input" autoload :Output, "rocket_job/batch/tabular/output" def initialize(map) @map = map end def [](category = :main) @map[category] || raise("No tabular map defined for category: #{category.inspect}") end # Iterate over responses and format using Tabular def render(row, category = :main) if row.is_a?(Batch::Results) results = Batch::Results.new row.each { |result| results << render(result) } results elsif row.is_a?(Batch::Result) row.value = self[row.category].render(row.value) row elsif row.blank? nil else self[category].render(row) end end def render_header(category = :main) self[category].render_header end def requires_header?(category = :main) self[category].requires_header? end def header?(category = :main) self[category].header? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rocketjob-6.0.0.rc3 | lib/rocket_job/batch/tabular.rb |
rocketjob-6.0.0.rc2 | lib/rocket_job/batch/tabular.rb |
rocketjob-6.0.0.rc1 | lib/rocket_job/batch/tabular.rb |