Class: Hotdog::Formatters::Ltsv

Inherits:
BaseFormatter show all
Defined in:
lib/hotdog/formatters/ltsv.rb

Instance Method Summary collapse

Instance Method Details

#format(result, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hotdog/formatters/ltsv.rb', line 6

def format(result, options={})
  if options[:fields]
    result.map { |row|
      options[:fields].zip(row).map { |column| column.join(":") }.join("\t")
    }.join("\n") + "\n"
  else
    result.map { |row|
      row.join("\t")
    }.join("\n") + "\n"
  end
end