Class: Genus
- Inherits:
-
Taxon
- Object
- ActiveRecord::Base
- Taxon
- Genus
show all
- Defined in:
- app/models/genus.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)
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'app/models/genus.rb', line 71
def self.create_from_fixup attributes
name = attributes[:name]
fossil = attributes[:fossil] || false
subfamily_id = attributes[:subfamily_id]
tribe_id = attributes[:tribe_id]
subfamily_id = Tribe.find(tribe_id).subfamily_id if tribe_id.present?
genus_group = Taxon.find_genus_group_by_name name
if genus_group
genus_group.update_attribute :tribe_id, tribe_id
Progress.log "FIXUP updated tribe for #{genus_group.type} #{genus_group.full_name}"
else
genus_group = Genus.create! name: name, status: 'valid', fossil: fossil, subfamily_id: subfamily_id,
tribe_id: tribe_id
Progress.log "FIXUP created genus #{genus_group.full_name}"
end
genus_group
end
|
+ (Object) import(data)
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
|
# File 'app/models/genus.rb', line 34
def self.import data
transaction do
protonym = Protonym.import data[:protonym]
headline_notes_taxt = Importers::Bolton::Catalog::TextToTaxt.convert(data[:note])
attributes = {
subfamily: data[:subfamily],
tribe: data[:tribe],
name: data[:name],
fossil: data[:fossil] || false,
status: data[:status] || 'valid',
synonym_of: data[:synonym_of],
protonym: protonym,
headline_notes_taxt: headline_notes_taxt,
}
attributes.merge! data[:attributes] if data[:attributes]
if data[:type_species]
type_species_taxt = Importers::Bolton::Catalog::TextToTaxt.convert(data[:type_species][:texts])
attributes[:type_taxon_taxt] = type_species_taxt
end
genus = create! attributes
data[:taxonomic_history].each do |item|
genus.taxonomic_history_items.create! taxt: item
end
type_species = data[:type_species]
if type_species
target_name = type_species[:genus_name]
target_name << ' (' << type_species[:subgenus_epithet] + ')' if type_species[:subgenus_epithet]
target_name << ' ' << type_species[:species_epithet]
ForwardReference.create! source_id: genus.id, target_name: target_name, fossil: type_species[:fossil]
end
genus
end
end
|
Instance Method Details
- (Object) children
12
13
14
|
# File 'app/models/genus.rb', line 12
def children
species
end
|
- (Object) full_label
16
17
18
|
# File 'app/models/genus.rb', line 16
def full_label
"<i>#{full_name}</i>"
end
|
- (Object) full_name
20
21
22
|
# File 'app/models/genus.rb', line 20
def full_name
name
end
|
- (Object) siblings
28
29
30
31
32
|
# File 'app/models/genus.rb', line 28
def siblings
tribe && tribe.genera ||
subfamily && subfamily.genera.without_tribe.all ||
Genus.without_subfamily.all
end
|
- (Object) statistics
24
25
26
|
# File 'app/models/genus.rb', line 24
def statistics
get_statistics [:species, :subspecies]
end
|