Class: Species
- Inherits:
-
Taxon
- Object
- ActiveRecord::Base
- Taxon
- Species
show all
- Defined in:
- app/models/species.rb
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Methods inherited from Taxon
#available?, #convert_asterisks_to_daggers!, #current_valid_name, #excluded?, find_genus_group_by_name, find_name, get_statistics, #get_statistics, #homonym?, #homonym_replaced_by?, #incertae_sedis_in?, #invalid?, massage_count, #rank, statistics, #synonym?, #synonym_of?, #unavailable?, #unidentifiable?, #unresolved_homonym?
Class Method Details
+ (Object) create_from_fixup(attributes)
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'app/models/species.rb', line 33
def self.create_from_fixup attributes
name = attributes[:name]
fossil = attributes[:fossil] || false
parts = name.split ' '
case parts.size
when 3
genus_name = parts[0]
subgenus_epithet = parts[1].gsub(/\(\)/, '')
species_epithet = parts[2]
when 2
genus_name = parts[0]
species_epithet = parts[1]
end
if attributes[:genus_id]
taxon = Genus.find attributes[:genus_id]
genus = taxon
elsif attributes[:subgenus_id]
taxon = Subgenus.find attributes[:subgenus_id]
genus = taxon.genus
else raise
end
species_attributes = {genus: genus, name: species_epithet, status: 'valid', fossil: fossil}
species_attributes[:subgenus_id] = attributes[:subgenus_id] if attributes[:subgenus_id]
if attributes[:genus_id]
species = Species.find_by_name_and_genus_id species_attributes[:name], taxon.id
elsif attributes[:subgenus_id]
species = Species.find_by_name_and_subgenus_id species_attributes[:name], taxon.id
else raise
end
unless species
species = Species.create! species_attributes
Progress.log "FIXUP created species #{species.full_name}"
end
species
end
|
Instance Method Details
- (Object) children
13
14
15
|
# File 'app/models/species.rb', line 13
def children
subspecies
end
|
- (Object) full_label
21
22
23
|
# File 'app/models/species.rb', line 21
def full_label
"<i>#{full_name}</i>"
end
|
- (Object) full_name
17
18
19
|
# File 'app/models/species.rb', line 17
def full_name
"#{genus.name} #{name}"
end
|
- (Object) set_subfamily
9
10
11
|
# File 'app/models/species.rb', line 9
def set_subfamily
self.subfamily = genus.subfamily if genus
end
|
- (Object) siblings
29
30
31
|
# File 'app/models/species.rb', line 29
def siblings
genus.species
end
|
- (Object) statistics
25
26
27
|
# File 'app/models/species.rb', line 25
def statistics
get_statistics [:subspecies]
end
|