Module: Ranks

Defined in:
lib/ranks.rb

Overview

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

Constant Summary collapse

CODES =

Duplicated somewhere?

[:iczn, :icn, :icnp, :icvcn].freeze

Class Method Summary collapse

Class Method Details

.lookup(code, rank) ⇒ String

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'



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ranks.rb', line 19

def self.lookup(code, rank)
  rank = rank.to_s
  raise "code '#{code}' is not a valid code" if !Ranks::CODES.include?(code)
  r = rank.downcase
  case code
    when :iczn
      ::ICZN_LOOKUP[r]
    when :icnp
      ::ICNP_LOOKUP[r]
    when :icvcn
      ::ICTV_LOOKUP[r]
    when :icn
      ::ICN_LOOKUP[r]
    else
      return false
  end
end

.valid?(rank) ⇒ Boolean

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.



11
12
13
# File 'lib/ranks.rb', line 11

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