Module: Export::Coldp::Files::Synonym

Defined in:
lib/export/coldp/files/synonym.rb

Overview

Bigger picture: understand how this maps to core name usage table in CoL

Class Method Summary collapse

Class Method Details

.generate(otus, reference_csv = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/export/coldp/files/synonym.rb', line 29

def self.generate(otus, reference_csv = nil)
  CSV.generate(col_sep: "\t") do |csv|

    csv << %w{taxonID nameID status remarks referenceID}

    # otus are valid and invalid
    otus.each do |o| 
      next unless o.taxon_name && o.taxon_name.is_valid?

      name = o.taxon_name
      data = ::Catalog::Nomenclature::Entry.new(name)

      data.names.each do |t|
        reified = !(t.is_valid? || t.type == 'Combination')

        references = reference_id_field(o)
        csv << [
          o.id,                                             # taxonID attached to the current valid concept
          (reified ? ::Export::Coldp.reified_id(t) : t.id), # nameID
          nil,                                              # status TODO def status(taxon_name_id)
          remarks_field, 
          references                                        # unclear what this means in TW
        ]

      end
    end
  end
end

.reference_id_field(otu) ⇒ Object



25
26
27
# File 'lib/export/coldp/files/synonym.rb', line 25

def self.reference_id_field(otu)
  nil
end

.remarks_fieldObject



21
22
23
# File 'lib/export/coldp/files/synonym.rb', line 21

def self.remarks_field
  nil 
end

.status(o, t) ⇒ Object

Returns:

  • String



11
12
13
14
15
16
17
18
19
# File 'lib/export/coldp/files/synonym.rb', line 11

def self.status(o, t)
  #'accepted'
  #'provisionally accepted'
  #'synonym'
  #'ambiguous synonym'
  #'missaplied'

  'synonym' 
end