Class: Spyro::ActionViewExtension::CollectionForHelper::Output::CSV
- Inherits:
-
Base
- Object
- Base
- Spyro::ActionViewExtension::CollectionForHelper::Output::CSV
show all
- Defined in:
- lib/spyro/collections/outputs/csv.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #t
Instance Method Details
#render ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/spyro/collections/outputs/csv.rb', line 23
def render
return "" if @unicollection.rows.empty?
::CSV.generate({}) do |csv|
csv
render_body csv
end
end
|
#render_body(csv) ⇒ Object
17
18
19
20
21
|
# File 'lib/spyro/collections/outputs/csv.rb', line 17
def render_body csv
@unicollection.rows.each do |row|
csv << row[:data].map(&:value)
end
end
|
12
13
14
15
|
# File 'lib/spyro/collections/outputs/csv.rb', line 12
def csv
return unless @unicollection.meta[:data]
csv << @unicollection.meta[:data]
end
|