Sha256: 6958946a4276dfdf26206107ff2e0c38b226c76c65e61ecacf0ec92af00f04f1

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

require 'csv'

module Polytrix
  module CLI
    module Reports
      class HashReporter
        def initialize(io = $stdout)
          @buffer = io
        end

        def print_table(table)
          headers = table[0]
          data = []
          table[1..-1].map do |row|
            row_data = {}
            row.each_with_index do |value, index|
              row_data[headers[index]] = value
            end
            data << row_data
          end
          @buffer.puts convert(data)
        end

        def convert(data)
          fail 'Subclass HashReporter and convert the data to the target format'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polytrix-0.1.0 lib/polytrix/cli/reports/hash_reporter.rb
polytrix-0.1.0.pre lib/polytrix/cli/reports/hash_reporter.rb