Module: Export::CSV::BiologicalAssociations::Simple

Defined in:
lib/export/csv/biological_associations/simple.rb

Constant Summary collapse

HEADERS =
%I{
  subject_order
  subject_family
  subject_genus
  subject
  subject_properties
  biological_relationships
  object_properties
  object
  object_order
  object_family
  object_genus
}.freeze

Class Method Summary collapse

Class Method Details

.csv(biological_associations) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/export/csv/biological_associations/simple.rb', line 17

def self.csv(biological_associations)

  data = ApplicationController.helpers.simple_hash(biological_associations)

  tbl = []
  tbl[0] = HEADERS.map(&:to_s)

  data.each do |h|
    tbl << HEADERS.collect{|c| h[c]}
  end

  output = StringIO.new
  tbl.each do |row|
    output.puts ::CSV.generate_line(row, col_sep: "\t", encoding: Encoding::UTF_8)
  end

  output.string
end