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

+ (String) lookup(code, rank)

Returns representing the name of the NomenclaturalRank class Ranks::lookup(:iczn, 'superfamily') # => 'NomenclaturalRank::Iczn::FamilyGroup::Superfamily'

Parameters:

  • code (Symbol)
  • rank (Symbol)

Returns:

  • (String)

    representing the name of the NomenclaturalRank class Ranks::lookup(:iczn, 'superfamily') # => 'NomenclaturalRank::Iczn::FamilyGroup::Superfamily'



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ranks.rb', line 16

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.

Parameters:

  • rank (String)

Returns:

  • (Boolean)

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



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

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