Class: Report::Csv::Table
- Inherits:
-
Struct
- Object
- Struct
- Report::Csv::Table
- Includes:
- Utils
- Defined in:
- lib/report/csv/table.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
Methods included from Utils
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent
3 4 5 |
# File 'lib/report/csv/table.rb', line 3 def parent @parent end |
#table ⇒ Object
Returns the value of attribute table
3 4 5 |
# File 'lib/report/csv/table.rb', line 3 def table @table end |
Instance Method Details
#cleanup ⇒ Object
24 25 26 |
# File 'lib/report/csv/table.rb', line 24 def cleanup safe_delete @path if @path end |
#path ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/report/csv/table.rb', line 5 def path return @path if defined?(@path) tmp_path = tmp_path(:hint => table.name, :extname => '.csv') File.open(tmp_path, 'wb') do |f| if table._head table._head.each(parent.report) do |row| f.write row.to_a.to_csv end f.write [].to_csv end if table._body f.write table._body.columns.map(&:name).to_csv table._body.each(parent.report) do |row| f.write row.to_a.to_csv end end end @path = tmp_path end |