Class: NomenclaturalRank

Inherits:
Object
  • Object
show all
Defined in:
app/models/nomenclatural_rank.rb

Overview

The base Class for all Nomenclature classes. The class of a TaxonName root. !! See /lib/Ranks for related Constants and Hooks

Direct Known Subclasses

Icn, Iczn

Defined Under Namespace

Classes: Icn, Iczn

Class Method Summary collapse

Class Method Details

.abbreviationObject



74
75
76
# File 'app/models/nomenclatural_rank.rb', line 74

def self.abbreviation
  nil
end

.bottom_rank(rank) ⇒ Object

Returns a NomenclaturalRank Class, the lowest assignable for the rank Class passed.



25
26
27
28
29
30
31
# File 'app/models/nomenclatural_rank.rb', line 25

def self.bottom_rank(rank)
  all = rank.descendants
  all.select!{|r| !r.parent_rank.nil?}
  all_parents = all.collect{|i| i.parent_rank}
  all.detect{|r| !all_parents.include?(r)}
#    all.detect { |r| !(r.parent_rank.nil? or all_parents.include?(r)) }
end

.nomenclatural_codeObject

returns a potentially_validating code name for this taxon



46
47
48
49
50
51
52
53
54
# File 'app/models/nomenclatural_rank.rb', line 46

def self.nomenclatural_code
  if ::ICZN.include?(self)
    return :iczn
  elsif ::ICN.include?(self)
    return :icn
  else
    return nil
  end
end

.nomenclatural_code_classObject

returns a potentially_validating code class for this taxon



57
58
59
60
61
62
63
64
65
# File 'app/models/nomenclatural_rank.rb', line 57

def self.nomenclatural_code_class
  if ::ICZN.include?(self)
    return NomenclaturalRank::Iczn
  elsif ::ICN.include?(self)
    return NomenclaturalRank::Icn
  else
    return nil
  end
end

.parent_rankObject

The Class representing the immediate parent rank. Required. Set to nil if a “root” level, this further implies that self can not be assigned as a Rank to a TaxonName



70
71
72
# File 'app/models/nomenclatural_rank.rb', line 70

def self.parent_rank
  nil
end

.rank_nameObject

Return a String with the “common” name for this rank.



35
36
37
38
39
40
41
42
43
# File 'app/models/nomenclatural_rank.rb', line 35

def self.rank_name
  n = self.name.demodulize.underscore.humanize.downcase
  if n == 'potentially_validating rank'
    n = 'root'
  elsif n == 'class rank'
    n = 'class'
  end
  n
end

.top_rank(rank) ⇒ Object

Returns a NomenclaturalRank Class, the highest assignable for the rank Class passed.



17
18
19
20
21
22
# File 'app/models/nomenclatural_rank.rb', line 17

def self.top_rank(rank)
  all = rank.descendants
  all.select!{|r| !r.parent_rank.nil?}
  all.detect{|r| !all.include?(r.parent_rank)}
#    all.detect { |r| !(r.parent_rank.nil? or all.include?(r.parent_rank)) }
end

.typical_useObject

Should the rank be displayed in “typical” use?



12
13
14
# File 'app/models/nomenclatural_rank.rb', line 12

def self.typical_use
  true
end

.valid_parentsObject



78
79
80
# File 'app/models/nomenclatural_rank.rb', line 78

def self.valid_parents
  []
end