Class: Hybrid

Inherits:
TaxonName show all
Defined in:
app/models/hybrid.rb

Overview

A hybrid taxon, defined by adding relationships to this anonymous node.

If only one name is asserted to be a hybrid (i.e. without reference to multiple names) then this can be indicated by creating a Protonym and applying the status of Hybrid.

Constant Summary

Constant Summary

Constants inherited from TaxonName

TaxonName::ALTERNATE_VALUES_FOR, TaxonName::EXCEPTED_FORM_TAXON_NAME_CLASSIFICATIONS, TaxonName::NOT_LATIN, TaxonName::NO_CACHED_MESSAGE, TaxonName::SPECIES_EPITHET_RANKS

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary

Attributes inherited from TaxonName

#also_create_otu, #cached, #cached_author_year, #cached_classified_as, #cached_higher_classification, #cached_html, #cached_misspelling, #cached_original_combination, #cached_primary_homonym, #cached_primary_homonym_alternative_spelling, #cached_secondary_homonym, #cached_secondary_homonym_alternative_spelling, #feminine_name, #masculine_name, #name, #neuter_name, #no_cached, #parent_id, #project_id, #rank_class, #type, #verbatim_author, #verbatim_name, #year_of_publication

Instance Method Summary (collapse)

Methods inherited from TaxonName

#all_taxon_name_relationships, #ancestor_at_rank, #ancestor_protonyms, #ancestors_through_parents, #author_string, #cached_html_name_and_author_year, #cached_name_and_author_year, #check_for_children, #check_new_parent_class, #check_new_rank_class, #classification_invalid_or_unavailable?, #classification_valid?, #combination_list_all, #combination_list_self, #combined_statuses, #create_new_combination_if_absent, #descendant_protonyms, #first_possible_valid_taxon_name, #first_possible_valid_taxon_name_relationship, #form_name_elements, #fossil?, #full_name_array, #full_name_hash, #gbif_status_array, #gender_class, #gender_instance, #gender_name, #genus_name_elements, #get_author_and_year, #get_cached_classified_as, #get_cached_misspelling, #get_genus_species, #get_original_combination, #get_valid_taxon_name, #hybrid?, #icn_author_and_year, #iczn_author_and_year, #is_combination?, #is_protonym?, #is_valid?, #list_of_invalid_taxon_names, #name_in_gender, #name_is_missapplied?, #name_with_misspelling, #next_sibling, #nomenclature_date, #parent_is_set?, #part_of_speech_class, #part_of_speech_instance, #part_of_speech_name, #previous_sibling, #rank, #rank_string, #related_taxon_names, #relationship_invalid?, #safe_self_and_ancestors, #section_name_elements, #series_name_elements, #set_cached_author_year, #set_cached_classified_as, #set_cached_names, #set_cached_names_for_dependants_and_self, #set_cached_original_combination, #set_cached_valid_taxon_name_id, #set_type_if_empty, sort_by_rank, #species_group_name_elements, #species_name_elements, #statuses_from_classifications, #statuses_from_relationships, #subform_name_elements, #subgenus_name_elements, #subsection_name_elements, #subseries_name_elements, #subspecies_name_elements, #subvariety_name_elements, #superspecies_name_elements, #sv_cached_names, #sv_combination_duplicates, #sv_fix_cached_names, #sv_fix_missing_author, #sv_fix_missing_year, #sv_fix_parent_is_valid_name, #sv_homotypic_synonyms, #sv_missing_classifications, #sv_missing_fields, #sv_missing_relationships, #sv_not_synonym_of_self, #sv_parent_is_valid_name, #sv_parent_priority, #sv_potential_homonyms, #sv_primary_types, #sv_single_sub_taxon, #sv_species_gender_agreement, #sv_two_unresolved_alternative_synonyms, #sv_type_placement, #sv_validate_coordinated_names, #sv_validate_name, #sv_validate_parent_rank, #synonyms, #taxon_name_classifications_for_statuses, #unavailable_or_invalid?, #update_cached_original_combinations, #validate_one_root_per_project, #validate_parent_is_set, #validate_parent_rank_is_higher, #validate_source_type, #variety_name_elements, with_taxon_name_relationship, #year_integer

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?

Instance Method Details

- (Object) get_full_name



25
26
27
28
# File 'app/models/hybrid.rb', line 25

def get_full_name
  hr = self.hybrid_relationships(true)
  hr.empty? ? '[HYBRID TAXA NOT SELECTED]' : hr.collect{|i| i.subject_taxon_name.cached}.sort.join(' x ')
end

- (Object) get_full_name_html



20
21
22
23
# File 'app/models/hybrid.rb', line 20

def get_full_name_html
  hr = self.hybrid_relationships(true)
  hr.empty? ? '[HYBRID TAXA NOT SELECTED]' : hr.collect{|i| i.subject_taxon_name.cached_html}.sort.join(' × ')
end

- (Object) set_cached



34
35
36
# File 'app/models/hybrid.rb', line 34

def set_cached
  self.cached = get_full_name
end

- (Object) set_cached_html



30
31
32
# File 'app/models/hybrid.rb', line 30

def set_cached_html
  self.cached_html = get_full_name_html
end

- (Object) sv_hybrid_name_relationships (protected)



44
45
46
47
48
49
50
51
# File 'app/models/hybrid.rb', line 44

def sv_hybrid_name_relationships
  case hybrid_relationships.count
  when 0
    soft_validations.add(:base, 'Hybrid is not linked to non hybrid taxa')
  when 1
    soft_validations.add(:base, 'Hybrid should be linked to at least two non hybrid taxa')
  end
end

- (Object) validate_rank_class_class (protected)



40
41
42
# File 'app/models/hybrid.rb', line 40

def validate_rank_class_class
  errors.add(:rank_class, 'It is not an ICN rank') unless ICN.include?(rank_string)
end