Class: INatGet::Data::Model::Taxon
- Inherits:
-
INatGet::Data::Model
- Object
- Sequel::Model
- INatGet::Data::Model
- INatGet::Data::Model::Taxon
- Includes:
- Comparable
- Defined in:
- lib/inat-get/data/models/taxon.rb
Sequel Associations collapse
-
#ancestors ⇒ Sequel::Dataset, Array<INatGet::Data::Model::Taxon>
Sequel many-to-many association.
-
#descendants ⇒ Sequel::Dataset, Array<INatGet::Data::Model::Taxon>
Sequel many-to-many association.
-
#iconic_taxon ⇒ INatGet::Data::Model::Taxon?
Sequel many-to-one association.
-
#identifications ⇒ Sequel::Dataset, Array<Identification>
Sequel one-to-many association.
-
#observations ⇒ Sequel::Dataset, Array<Observation>
Sequel one-to-many association.
-
#parent ⇒ INatGet::Data::Model::Taxon?
Sequel many-to-one association.
Sequel Fields collapse
-
#cached ⇒ Time
Sequel data field.
-
#common_name ⇒ String?
Sequel data field.
-
#english_name ⇒ String?
Sequel data field.
-
#iconic_taxon_id ⇒ Integer?
Sequel data field.
-
#id ⇒ Integer
Sequel data field.
-
#is_active ⇒ Boolean
Sequel data field.
-
#name ⇒ String
Sequel data field.
-
#parent_id ⇒ Integer?
Sequel data field.
-
#rank ⇒ String?
Sequel data field.
-
#rank_level ⇒ Float?
Sequel data field.
Taxonomy collapse
Sorting collapse
Fixed Taxon Levels collapse
Methods inherited from INatGet::Data::Model
helper, manager, parser, updater
Instance Attribute Details
#ancestors ⇒ Sequel::Dataset, Array<INatGet::Data::Model::Taxon>
Sequel many-to-many association.
19 |
# File 'lib/inat-get/data/models/taxon.rb', line 19 many_to_many :ancestors, class: INatGet::Data::Model::Taxon, join_table: :taxa_ancestors, left_key: :taxon_id, right_key: :ancestor_id |
#cached ⇒ Time
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#common_name ⇒ String?
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#descendants ⇒ Sequel::Dataset, Array<INatGet::Data::Model::Taxon>
Sequel many-to-many association.
20 |
# File 'lib/inat-get/data/models/taxon.rb', line 20 many_to_many :descendants, class: INatGet::Data::Model::Taxon, join_table: :taxa_ancestors, left_key: :ancestor_id, right_key: :taxon_id |
#english_name ⇒ String?
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#iconic_taxon ⇒ INatGet::Data::Model::Taxon?
Sequel many-to-one association.
16 |
# File 'lib/inat-get/data/models/taxon.rb', line 16 many_to_one :iconic_taxon, class: INatGet::Data::Model::Taxon |
#iconic_taxon_id ⇒ Integer?
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#id ⇒ Integer
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#identifications ⇒ Sequel::Dataset, Array<Identification>
Sequel one-to-many association.
14 |
# File 'lib/inat-get/data/models/taxon.rb', line 14 one_to_many :identifications |
#is_active ⇒ Boolean
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#name ⇒ String
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#observations ⇒ Sequel::Dataset, Array<Observation>
Sequel one-to-many association.
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 one_to_many :observations |
#parent ⇒ INatGet::Data::Model::Taxon?
Sequel many-to-one association.
17 |
# File 'lib/inat-get/data/models/taxon.rb', line 17 many_to_one :parent, class: INatGet::Data::Model::Taxon |
#parent_id ⇒ Integer?
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#rank ⇒ String?
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
#rank_level ⇒ Float?
Sequel data field
11 |
# File 'lib/inat-get/data/models/taxon.rb', line 11 set_dataset :taxa |
Class Method Details
.compact_set(*values) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/inat-get/data/models/taxon.rb', line 26 def compact_set *values result = ::Set[] values.each do |value| found = result.find { |v| v === value } next if found found = result.find { |v| value === v } result.delete found if found result << value end result end |
Instance Method Details
#<=>(other) ⇒ Object
86 87 88 89 90 |
# File 'lib/inat-get/data/models/taxon.rb', line 86 def <=> other return nil unless other.is_a?(INatGet::Data::Model::Taxon) return 0 if other.id == self.id [ self.iconic, self.name ] <=> [ other.iconic, other.name ] end |
#===(nil) ⇒ false #===(taxon) ⇒ Boolean #===(item) ⇒ Boolean #===(other) ⇒ nil
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/inat-get/data/models/taxon.rb', line 57 def === other case other when nil false when INatGet::Data::Model::Taxon return true if self.id == other.id Taxon.where(id: other.id) .where(id: Taxon.select(:taxon_id) .from(:taxa_ancestors) .where(ancestor_id: self.id)) .any? when INatGet::Data::Model::Observation, INatGet::Data::Model::Identification self === value.taxon else nil end end |
#iconic ⇒ INatGet::Data::Enum::Iconic
80 81 82 |
# File 'lib/inat-get/data/models/taxon.rb', line 80 def iconic INatGet::Data::Enum::Iconic::by_id self.iconic_taxon_id end |
#on_rank(*ranks) ⇒ Taxon
97 98 99 100 |
# File 'lib/inat-get/data/models/taxon.rb', line 97 def on_rank *ranks ranks = ranks.map(&:to_s) self.ancestors_dataset.where(rank: ranks).first end |