Sha256: 676df609e8372eb3dea8d4bfc70cfb9eeefc61ccaa01c74568df3115f85de966

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

module Ec2spec
  module Formatter
    module PlainTextFormatter
      def output(results, hosts)
        table = Terminal::Table.new
        table.headings = table_header(results)
        table.rows = table_rows(results)
        column_count = hosts.size + 1
        column_count.times { |i| table.align_column(i, :right) }
        table
      end

      def table_header(results)
        [''].concat(results.map(&:host))
      end

      def table_rows(results)
        Ec2spec::HostResult.label_with_methods
                           .each_with_object([]) do |(k, v), row|
          unit = PriceCalculator.instance.currency_unit
          label = format(k, unit)
          row << [label].concat(results.map(&v))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ec2spec-0.1.3 lib/ec2spec/formatter/plain_text_formatter.rb