Class: TaxonNameClassification::Latinized::PartOfSpeech

Inherits:
TaxonNameClassification::Latinized show all
Defined in:
app/models/taxon_name_classification/latinized/part_of_speech.rb

Direct Known Subclasses

Adjective, NounInApposition, NounInGenitiveCase, Participle

Defined Under Namespace

Classes: Adjective, NounInApposition, NounInGenitiveCase, Participle

Constant Summary

NOMEN_URI =
'http://purl.obolibrary.org/obo/NOMEN_0000046'

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary

Attributes inherited from TaxonNameClassification

#project_id, #taxon_name_id, #type

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from TaxonNameClassification::Latinized

assignable

Methods inherited from TaxonNameClassification

#annotated_object, annotates?, assignable, #classification_label, code_applicability_end_year, code_applicability_start_year, collect_descendants_and_itself_to_s, collect_descendants_to_s, collect_to_s, disjoint_taxon_name_classes, gbif_status, label, #nomen_id, nomen_uri, #nomenclature_code, #nomenclature_code_matches, possible_genus_endings, possible_species_endings, questionable_species_endings, #set_cached, #set_cached_names_for_taxon_names, #sv_not_specific_classes, #sv_proper_classification, #sv_validate_disjoint_classes, #type_class, #type_class=, #type_name, #validate_taxon_name_classification, #validate_uniqueness_of_latinized

Methods included from SoftValidation

#clear_soft_validations, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods included from ActiverecordUtilities

#trim_attributes

Class Method Details

+ (Object) applicable_ranks



5
6
7
# File 'app/models/taxon_name_classification/latinized/part_of_speech.rb', line 5

def self.applicable_ranks
  SPECIES_RANK_NAMES
end

Instance Method Details

- (Object) set_gender_in_taxon_name (protected)

A set_cached helper, see Participle, Adjective



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/taxon_name_classification/latinized/part_of_speech.rb', line 12

def set_gender_in_taxon_name
  t = taxon_name
  if t.masculine_name.blank? && t.feminine_name.blank? && t.neuter_name.blank?
    n = t.name
    m_name, f_name, n_name = nil, nil, nil

    case n
    when /is$/
      m_name, f_name, n_name = t.name, t.name, t.name[0..-3] + 'e'
    when /e$/
      m_name, f_name, n_name = t.name[0..-2] + 'is', t.name[0..-2] + 'is', t.name
    when /us$/
      m_name, f_name, n_name = t.name, t.name[0..-3] + 'a', t.name[0..-3] + 'um'
    when /er$/
      m_name, f_name, n_name = t.name, t.name[0..-3] + 'ra', t.name[0..-3] + 'rum'
    when /(um|rum)$/
      m_name, f_name, n_name = t.name[0..-3] + 'us', t.name[0..-3] + 'a', t.name
    when /(a|ra)$/
      m_name, f_name, n_name = t.name[0..-3] + 'us', t.name, t.name[0..-3] + 'um'
    when /or$/
      # TODO: Move check for names ending in `or` to soft valdiation vs. Partciple/Adjective (combination shouldn't exist) 
    else
    end

    t.update_columns(
      :masculine_name => m_name,
      :feminine_name => f_name,
      :neuter_name => n_name
    )
  end
end