Class: Hybrid

Inherits:
TaxonName
  • Object
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.

Instance Method Summary collapse

Instance Method Details

#get_full_nameObject



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

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

#get_full_name_html(name = nil) ⇒ Object

TODO: get rid of bogus params signature call



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

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

#set_cached_is_validObject

Overridden here, not applicable to this class



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

def set_cached_is_valid
  true
end

#set_cached_valid_taxon_name_idObject

Overridden here, not applicable to this class



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

def set_cached_valid_taxon_name_id
  true 
end

#sv_hybrid_name_relationshipsObject (protected)



50
51
52
53
54
55
56
57
# File 'app/models/hybrid.rb', line 50

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

#validate_rank_class_classObject (protected)



46
47
48
# File 'app/models/hybrid.rb', line 46

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