Module: Autoselect::Levels::ColRecordLabel
- 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
-
#col_author_year(record) ⇒ String?
private
The display author+year for a CoL result.
- #record_label(record) ⇒ Object
- #record_label_html(record, term = nil) ⇒ Object
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.)
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 (record) ext = record._col_extension return nil unless ext = ext[:col_authorship].presence return nil unless code = ext[:col_code].presence return if code && code != 'zoological' if (leading_parenthetical = [/\A\([^)]*\)/]) leading_parenthetical else 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, (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, (record)] .compact .map { |part| ERB::Util.html_escape(part) } .join(' ') end |