Class: HanselCore::CsvFormatter
- Inherits:
-
Object
- Object
- HanselCore::CsvFormatter
- Defined in:
- lib/hansel/formatting/csv_formatter.rb
Overview
Output to csv format
Constant Summary collapse
- COLUMNS =
%w( rate replies connection_rate request_rate reply_time net_io errors status reply_rate_min reply_rate_avg reply_rate_max reply_rate_stddev server port num_conns )
Class Method Summary collapse
Class Method Details
.format(results) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/hansel/formatting/csv_formatter.rb', line 22 def self.format results @csv = "" line '# ' + CSV.generate_line(COLUMNS) results.each { |data| format_line data } unless results.empty? @csv end |
.format_line(data) ⇒ Object
18 19 20 |
# File 'lib/hansel/formatting/csv_formatter.rb', line 18 def self.format_line data line CSV.generate_line( COLUMNS.map { |column| data.send column.to_sym } ) end |
.line(text) ⇒ Object
13 14 15 16 |
# File 'lib/hansel/formatting/csv_formatter.rb', line 13 def self.line text @csv << text @csv << "\n" end |