Module: Ohmage::CliHelpers

Included in:
CLI
Defined in:
lib/ohmage/cli_helpers.rb

Class Method Summary collapse

Class Method Details

.format_output(d, table, fields, no_table_field) ⇒ Object

rubocop:disable MethodLength



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ohmage/cli_helpers.rb', line 5

def self.format_output(d, table, fields, no_table_field) # rubocop:disable MethodLength
  # accepts an ohmage entity array and returns output (table or newline given table boolean)
  output = []
  d.each do |i|
    @line = {}
    fields.each do |f|
      @line.merge!(f.to_sym => i.send(f).to_s)
    end
    output << @line
  end
  if table
    Formatador.display_compact_table(output, fields)
  else
    output.each do |v|
      Formatador.display_line(v[no_table_field])
    end
  end
end