Module: Export::CSV::Dwc::Extension::BiologicalAssociations

Defined in:
lib/export/csv/dwc/extension/biological_associations.rb

Overview

CSV for for a ResourceRelationship based extension

Constant Summary collapse

HEADERS =

See also BiologicalAssociation::DwcExtensions::DWC_EXTENSION_MAP, the two play off each other. Maintain this for order.

%w{
  resourceRelationshipID
  resourceID
  resource
  relationshipOfResourceID
  relationshipOfResource
  relatedResourceID
  relatedResource 
  relationshipAccordingTo
  relationshipEstablishedDate
  relationshipRemarks
}.freeze

Class Method Summary collapse

Class Method Details

.csv(scope) ⇒ Object



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

def self.csv(scope)
  tbl = []
  tbl[0] = HEADERS

  scope.find_each do |b|
    tbl << b.darwin_core_extension_row
  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