Module: Ranks

Defined in:
lib/ranks.rb

Overview

Contains methods used in /config/initializers/constants/ranks.rb to generate Rank Classes

Class Method Summary (collapse)

Class Method Details

+ (Object) lookup(code, rank)

Returns a String representing the name of the NomenclaturalRank class

Ranks::lookup(:iczn, 'superfamily')   # => 'NomenclaturalRank::Iczn::FamilyGroup::Superfamily'


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ranks.rb', line 13

def self.lookup(code, rank)
  rank = rank.to_s
  raise if ![:iczn, :icn].include?(code)
  r = rank.downcase
  case code
    when :iczn
      ::ICZN_LOOKUP[r]
    when :icn
      ::ICN_LOOKUP[r]
    else
      return false
  end
end

+ (Boolean) valid?(rank)

Returns true if rank.to_s is the name of a NomenclaturalRank.

Returns:

  • (Boolean)


7
8
9
# File 'lib/ranks.rb', line 7

def self.valid?(rank)
   ::RANKS.include?(rank.to_s) 
end