Method: Collins::CLI::Formatter#format_pools

Defined in:
lib/collins/cli/formatter.rb

#format_pools(pools, opts = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/collins/cli/formatter.rb', line 14

def format_pools(pools, opts = {})
  if pools.length > 0
    opts = FORMATTING_DEFAULTS.merge(opts)
    # map the hashes into openstructs that will respond to #send(:name)
    ostructs = pools.map { |p| OpenStruct.new(Hash[p.map {|k,v| [k.downcase,v]}]) }
    display_as_table(ostructs, ADDRESS_POOL_COLUMNS, opts[:separator], opts[:show_header])
  else
    raise "No pools found"
  end
end