Class: Terrazzo::CsvExport
- Inherits:
-
Object
- Object
- Terrazzo::CsvExport
- Defined in:
- lib/terrazzo/csv_export.rb
Instance Attribute Summary collapse
-
#dashboard ⇒ Object
readonly
Returns the value of attribute dashboard.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
-
#initialize(dashboard, resources) ⇒ CsvExport
constructor
A new instance of CsvExport.
- #to_csv ⇒ Object
Constructor Details
#initialize(dashboard, resources) ⇒ CsvExport
Returns a new instance of CsvExport.
8 9 10 11 |
# File 'lib/terrazzo/csv_export.rb', line 8 def initialize(dashboard, resources) @dashboard = dashboard @resources = resources end |
Instance Attribute Details
#dashboard ⇒ Object (readonly)
Returns the value of attribute dashboard.
6 7 8 |
# File 'lib/terrazzo/csv_export.rb', line 6 def dashboard @dashboard end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
6 7 8 |
# File 'lib/terrazzo/csv_export.rb', line 6 def resources @resources end |
Instance Method Details
#to_csv ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/terrazzo/csv_export.rb', line 13 def to_csv CSV.generate(headers: true) do |csv| csv << attributes.map { |attr| header_for(attr) } resources.each do |resource| csv << attributes.map { |attr| value_for(resource, attr) } end end end |