Module: Export::CSV::Globi

Defined in:
lib/export/csv/globi.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{
  sourceOccurrenceId
  sourceCatalogNumber
  sourceCollectionCode
  sourceCollectionId:
  sourceInstitutionCode
  sourceTaxonId
  sourceTaxonName
  sourceTaxonRank
  sourceTaxonPathIds
  sourceTaxonPath
  sourceTaxonPathNames
  sourceBodyPartId
  sourceBodyPartName
  sourceLifeStageId
  sourceLifeStageName
  sourceSexId
  sourceSexName
  interactionTypeId
  interactionTypeName
  targetOccurrenceId
  targetCatalogNumber
  targetCollectionCode
  targetCollectionId
  targetInstitutionCode
  targetTaxonId
  targetTaxonName
  targetTaxonRank
  targetTaxonPathIds
  targetTaxonPath
  targetTaxonPathNames
  targetBodyPartId
  targetBodyPartName
  targetLifeStageId
  targetLifeStageName
  targetSexId
  targetSexName
  basisOfRecordId
  basisOfRecordName
  'http://rs.tdwg.org/dwc/terms/eventDate'
  decimalLatitude
  decimalLongitud
  localityId
  localityName
  referenceDoi
  referenceUrl
  referenceCitation
  namespace
  citation
  archiveURI
  lastSeenAt
  contentHash
  eltonVersion: nil
}.freeze

Class Method Summary collapse

Class Method Details

.csv(scope) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/export/csv/globi.rb', line 62

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

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