Sha256: ae39fa5314f6c2e6281ec6204c0448c702d2f3fd4969866ff2f2e3e57dfc5fef

Contents?: true

Size: 301 Bytes

Versions: 7

Compression:

Stored size: 301 Bytes

Contents

require "json"

class CliFormat::Presenter
  class Json < Base
    def text
      json_data = @rows.map do |row|
        item = {}
        @header.each_with_index do |header, i|
          item[header] = row[i]
        end
        item
      end
      JSON.pretty_generate(json_data)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cli-format-0.6.0 lib/cli_format/presenter/json.rb
cli-format-0.5.0 lib/cli_format/presenter/json.rb
cli-format-0.4.0 lib/cli_format/presenter/json.rb
cli-format-0.3.0 lib/cli_format/presenter/json.rb
cli-format-0.2.2 lib/cli_format/presenter/json.rb
cli-format-0.2.1 lib/cli_format/presenter/json.rb
cli-format-0.2.0 lib/cli_format/presenter/json.rb