Module: Autoselect::Levels::ColRecordLabel

Included in:
TaxonName::Levels::CatalogueOfLife, TaxonName::Levels::ColValidName
Defined in:
lib/autoselect/levels/col_record_label.rb

Overview

lib/autoselect/levels/col_record_label.rb record_label / record_label_html for the TaxonName CoL levels (catalogue_of_life, col_valid_name): the CoL name followed by its original author+year.

Instance Method Summary collapse

Instance Method Details

#col_author_year(record) ⇒ String? (private)

The display author+year for a CoL result.

CoL renders a recombination's authorship as the original (basionym) author+year wrapped in parens, followed by the combination authorship, e.g. "(Chatton, 1925) Whittaker & Margulis, 1978". Per ICZN convention we show only the original author+year, keeping the parens that signal the recombination. A name described in its original genus has no leading parenthetical and is shown verbatim, e.g. "Linnaeus, 1758".

Other codes cite both authors, e.g. botanical "(Moench) Voss", so a name whose CoL code is known and not zoological is shown verbatim too. (No code is treated as zoological, as in Vendor::Colrapi.rank_class_for.)

Returns:

  • (String, nil)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/autoselect/levels/col_record_label.rb', line 36

def col_author_year(record)
  ext = record._col_extension
  return nil unless ext

  authorship = ext[:col_authorship].presence
  return nil unless authorship

  code = ext[:col_code].presence
  return authorship if code && code != 'zoological'

  if (leading_parenthetical = authorship[/\A\([^)]*\)/])
    leading_parenthetical
  else
    authorship
  end
end

#record_label(record) ⇒ Object



7
8
9
10
11
# File 'lib/autoselect/levels/col_record_label.rb', line 7

def record_label(record)
  [record.cached.to_s.presence, col_author_year(record)]
    .compact
    .join(' ')
end

#record_label_html(record, term = nil) ⇒ Object



13
14
15
16
17
18
# File 'lib/autoselect/levels/col_record_label.rb', line 13

def record_label_html(record, term = nil)
  [record.cached.to_s.presence, col_author_year(record)]
    .compact
    .map { |part| ERB::Util.html_escape(part) }
    .join(' ')
end