class Ey::Core::Cli::Helpers::StreamPrinter::Printer
Public Class Methods
new(rows = {})
click to toggle source
# File lib/ey-core/cli/helpers/stream_printer.rb, line 12 def initialize(rows = {}) @rows = rows end
Public Instance Methods
format(value, width)
click to toggle source
# File lib/ey-core/cli/helpers/stream_printer.rb, line 33 def format(value, width) TablePrint::FixedWidthFormatter.new(width).format(value) end
print(*vals)
click to toggle source
# File lib/ey-core/cli/helpers/stream_printer.rb, line 15 def print(*vals) unless @header_printed header = [] separator = [] @rows.each do |k,v| header << format(k, v) separator << '-' * v end puts header.join("| ") puts separator.join("|-") @header_printed = true end line = [] vals.each_with_index do |v,index| line << format(v, @rows.values[index]) end puts line.join("| ") end