Class: Adhoq::Reporter::Csv
- Inherits:
-
Object
- Object
- Adhoq::Reporter::Csv
- Defined in:
- lib/adhoq/reporter/csv.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_report ⇒ Object
-
#initialize(result) ⇒ Csv
constructor
A new instance of Csv.
Constructor Details
#initialize(result) ⇒ Csv
Returns a new instance of Csv.
11 12 13 |
# File 'lib/adhoq/reporter/csv.rb', line 11 def initialize(result) @result = result end |
Class Method Details
.mime_type ⇒ Object
7 8 9 |
# File 'lib/adhoq/reporter/csv.rb', line 7 def self.mime_type 'text/csv; charset=UTF-8' end |
Instance Method Details
#build_report ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/adhoq/reporter/csv.rb', line 15 def build_report file = Tempfile.new(['adhoq-reporter', '.csv'], Dir.tmpdir, encoding: 'UTF-8') csv = CSV.new(file) csv << @result.header @result.rows.each {|row| csv << row } file.tap(&:rewind) end |