Class: INatGet::Data::Model::Taxon
- Inherits:
-
INatGet::Data::Model
- Object
- Sequel::Model
- INatGet::Data::Model
- INatGet::Data::Model::Taxon
- Includes:
- Comparable, Identified
- 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 included from Identified
Methods inherited from INatGet::Data::Model
endpoint, helper, manager, parser, updater
Instance Attribute Details
#ancestors ⇒ Sequel::Dataset, Array<INatGet::Data::Model::Taxon>
Sequel many-to-many association.
21 |
# File 'lib/inat-get/data/models/taxon.rb', line 21 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
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#common_name ⇒ String?
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#descendants ⇒ Sequel::Dataset, Array<INatGet::Data::Model::Taxon>
Sequel many-to-many association.
22 |
# File 'lib/inat-get/data/models/taxon.rb', line 22 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
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#iconic_taxon ⇒ INatGet::Data::Model::Taxon?
Sequel many-to-one association.
18 |
# File 'lib/inat-get/data/models/taxon.rb', line 18 many_to_one :iconic_taxon, class: INatGet::Data::Model::Taxon |
#iconic_taxon_id ⇒ Integer?
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#id ⇒ Integer
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#identifications ⇒ Sequel::Dataset, Array<Identification>
Sequel one-to-many association.
16 |
# File 'lib/inat-get/data/models/taxon.rb', line 16 one_to_many :identifications |
#is_active ⇒ Boolean
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#name ⇒ String
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#observations ⇒ Sequel::Dataset, Array<Observation>
Sequel one-to-many association.
15 |
# File 'lib/inat-get/data/models/taxon.rb', line 15 one_to_many :observations |
#parent ⇒ INatGet::Data::Model::Taxon?
Sequel many-to-one association.
19 |
# File 'lib/inat-get/data/models/taxon.rb', line 19 many_to_one :parent, class: INatGet::Data::Model::Taxon |
#parent_id ⇒ Integer?
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#rank ⇒ String?
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
#rank_level ⇒ Float?
Sequel data field
13 |
# File 'lib/inat-get/data/models/taxon.rb', line 13 set_dataset :taxa |
Class Method Details
.compact_set(*values) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/inat-get/data/models/taxon.rb', line 28 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
88 89 90 91 92 |
# File 'lib/inat-get/data/models/taxon.rb', line 88 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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/inat-get/data/models/taxon.rb', line 59 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
82 83 84 |
# File 'lib/inat-get/data/models/taxon.rb', line 82 def iconic INatGet::Data::Enum::Iconic::by_id self.iconic_taxon_id end |
#on_rank(*ranks) ⇒ Taxon
99 100 101 102 |
# File 'lib/inat-get/data/models/taxon.rb', line 99 def on_rank *ranks ranks = ranks.map(&:to_s) self.ancestors_dataset.where(rank: ranks).first end |