Class: JCF::CLI::OutputFormatters::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/jcf/cli/output_formatters/text.rb

Class Method Summary collapse

Class Method Details

.format(data:, tree: false) ⇒ String

data: { header1: %w[name1 name2], header2: %w[space1 space2]} output: ┌────────┬────────┐ │header1 │header2 │ ├────────┼────────┤ │name1 │space1 │ │name2 │space2 │ └────────┴────────┘

Parameters:

  • data (Hash)

    the data to be formatted

  • tree (Boolean) (defaults to: false)

    whether to format as a tree or a table

Returns:

  • (String)

    the formatted data



23
24
25
26
27
28
29
30
31
# File 'lib/jcf/cli/output_formatters/text.rb', line 23

def format(data:, tree: false)
  return "" if data.nil? || data.empty?

  if tree
    render_tree(data)
  else
    render_data(data)
  end
end