Module: TypedPrint

Defined in:
lib/typed_print.rb,
lib/typed_print/table.rb,
lib/typed_print/version.rb

Defined Under Namespace

Classes: Table

Constant Summary collapse

VERSION =
"0.4.0"

Class Method Summary collapse

Class Method Details



7
8
9
10
# File 'lib/typed_print.rb', line 7

def self.print(data, align: {}, only: nil, headers: {}, format: :plain, color: false, colors: nil)
  puts table(data, align: align, only: only, headers: headers, format: format, color: color, colors: colors)
  nil
end

.save(data, path, only: nil, headers: {}, delimiter: ",") ⇒ Object



22
23
24
25
26
# File 'lib/typed_print.rb', line 22

def self.save(data, path, only: nil, headers: {}, delimiter: ",")
  csv = to_csv(data, only: only, headers: headers, delimiter: delimiter)
  File.write(path, "\xEF\xBB\xBF" + csv, encoding: "UTF-8")
  nil
end

.table(data, align: {}, only: nil, headers: {}, format: :plain, color: false, colors: nil) ⇒ Object



12
13
14
15
# File 'lib/typed_print.rb', line 12

def self.table(data, align: {}, only: nil, headers: {}, format: :plain, color: false, colors: nil)
  table_obj = TypedPrint::Table.new(data, align, only, headers, color: color, colors: colors)
  table_obj.render(format)
end

.to_csv(data, only: nil, headers: {}, delimiter: ",") ⇒ Object



17
18
19
20
# File 'lib/typed_print.rb', line 17

def self.to_csv(data, only: nil, headers: {}, delimiter: ",")
  table_obj = TypedPrint::Table.new(data, {}, only, headers)
  table_obj.to_csv(col_sep: delimiter)
end