class Crowbar::Client::Formatter::Hash

Formatter to properly print out hashes in different formats

Public Instance Methods

empty?() click to toggle source
# File lib/crowbar/client/formatter/hash.rb, line 27
def empty?
  options[:values].empty?
end

Protected Instance Methods

process_json() click to toggle source
# File lib/crowbar/client/formatter/hash.rb, line 46
def process_json
  JSON.pretty_generate(
    options[:values]
  )
end
process_plain() click to toggle source
# File lib/crowbar/client/formatter/hash.rb, line 40
def process_plain
  options[:values].map do |value|
    value.values.join(" ")
  end.join("\n")
end
process_table() click to toggle source
# File lib/crowbar/client/formatter/hash.rb, line 33
def process_table
  Terminal::Table.new(
    rows: options[:values].map(&:values),
    headings: options[:headings]
  )
end