The species name model is just a pointer to 5 Taxonifi::Model::Names. The various metadata (author, year, original combination) is stored with the individual instances of those names. Taxonifi::Model::Names have no ids!
# File lib/models/species_name.rb, line 16 def initialize(options = {}) opts = { }.merge!(options) build(ATTRIBUTES, opts) true end
Return a string representation of the species name.
# File lib/models/species_name.rb, line 68 def display_name strs = [] self.names.each do |n| case n.rank when 'subgenus' strs.push "(#{n.name})" else strs.push n.name end end strs.push self.names.last.author_year txt = strs.compact.join(" ") txt end
Set the genus name.
# File lib/models/species_name.rb, line 24 def genus=(genus) @genus = genus end
Return an array of Name objects.
# File lib/models/species_name.rb, line 63 def names ATTRIBUTES.collect{|a| self.send(a)}.compact end
Set the parent name.
# File lib/models/species_name.rb, line 50 def parent=(parent) if parent.class != Taxonifi::Model::Name raise SpeciesNameError, "Parent is not a Taxonifi::Model::Name." end if parent.rank.nil? || (Taxonifi::RANKS.index('genus') <= Taxonifi::RANKS.index(parent.rank)) raise Taxonifi::SpeciesNameError, "Parents of SpeciesNames must have rank higher than Genus." end @parent = parent end
Set the species name.
# File lib/models/species_name.rb, line 36 def species=(species) raise Taxonifi::SpeciesNameError, "Species name must have a Genus name before species can be assigned" if @genus.nil? @species = species @species.parent = (@subgenus ? @subgenus : @genus) end
Set the subgenus name.
# File lib/models/species_name.rb, line 29 def subgenus=(subgenus) raise Taxonifi::SpeciesNameError, "Species name must have a Genus name before subgenus can be assigned" if @genus.nil? @subgenus = subgenus @subgenus.parent = @genus end
Set the subspecies name.
# File lib/models/species_name.rb, line 43 def subspecies=(subspecies) raise Taxonifi::SpeciesNameError, "Subspecies name must have a species name before species can be assigned" if @species.nil? @subspecies = subspecies @subspecies.parent = @species end