Class: INat::Entity::Taxon

Inherits:
Data::Entity show all
Includes:
Data::Types, INat::Entity
Defined in:
lib/inat/data/entity/taxon.rb

Fields collapse

Attributes inherited from Data::Entity

#id

Instance Method Summary collapse

Methods included from Data::Types

#radius, radius, #sector, sector

Methods inherited from Data::Entity

by_id, #complete?, ddl, fetch, from_db_rows, #get, #init, #initialize, load, load_file, parse, read, #save, #to_db, #update

Methods included from App::Logger::DSL

#debug, debug, echo, #echo, error, #error, #info, info, log, #log, #warning, warning

Methods inherited from Data::Model

DDL, api_limit, api_part, api_path, backs, block, field, fields, has_path?, has_table?, #ignore, #initialize, links, #post_update, #process?, #saved?, table, #to_h, #update

Constructor Details

This class inherits a constructor from INat::Data::Entity

Instance Attribute Details

#ancestorsArray<item_type: Taxon>

Returns the ancestors field.

Returns:

  • (Array<item_type: Taxon>)

    the ancestors field



58
# File 'lib/inat/data/entity/taxon.rb', line 58

links :ancestors, item_type: Taxon, link_field: :ancestor_id

#childrenArray<item_type: Taxon>

Returns the children field.

Returns:

  • (Array<item_type: Taxon>)

    the children field



61
# File 'lib/inat/data/entity/taxon.rb', line 61

backs :children, item_type: Taxon, ids_field: :child_ids, back_field: :parent_id, owned: false

#created_attype: Time

Returns the created_at field.

Returns:

  • (type: Time)

    the created_at field



43
# File 'lib/inat/data/entity/taxon.rb', line 43

field :created_at, type: Time

#default_phototype: Photo

Returns the default_photo field.

Returns:

  • (type: Photo)

    the default_photo field



44
# File 'lib/inat/data/entity/taxon.rb', line 44

field :default_photo, type: Photo

#endemictype: Boolean

field :ancestry, type: Ancestry field :min_species_ancestry, type: Ancestry

Returns:

  • (type: Boolean)

    the endemic field



32
# File 'lib/inat/data/entity/taxon.rb', line 32

field :endemic, type: Boolean

#english_common_nametype: String

Returns the english_common_name field.

Returns:

  • (type: String)

    the english_common_name field



55
# File 'lib/inat/data/entity/taxon.rb', line 55

field :english_common_name, type: String

#extincttype: Boolean

Returns the extinct field.

Returns:

  • (type: Boolean)

    the extinct field



42
# File 'lib/inat/data/entity/taxon.rb', line 42

field :extinct, type: Boolean

#iconic_taxontype: Taxon

Returns the iconic_taxon field.

Returns:

  • (type: Taxon)

    the iconic_taxon field



33
# File 'lib/inat/data/entity/taxon.rb', line 33

field :iconic_taxon, type: Taxon

#iconic_taxon_nametype: IconicTaxa

Returns the iconic_taxon_name field.

Returns:

  • (type: IconicTaxa)

    the iconic_taxon_name field



52
# File 'lib/inat/data/entity/taxon.rb', line 52

field :iconic_taxon_name, type: IconicTaxa, index: true

#introducedtype: Boolean

Returns the introduced field.

Returns:

  • (type: Boolean)

    the introduced field



37
# File 'lib/inat/data/entity/taxon.rb', line 37

field :introduced, type: Boolean

#is_activetype: Boolean

Returns the is_active field.

Returns:

  • (type: Boolean)

    the is_active field



29
# File 'lib/inat/data/entity/taxon.rb', line 29

field :is_active, type: Boolean, index: true

#min_species_taxontype: Taxon

Returns the min_species_taxon field.

Returns:

  • (type: Taxon)

    the min_species_taxon field



34
# File 'lib/inat/data/entity/taxon.rb', line 34

field :min_species_taxon, type: Taxon

#nametype: String

Returns the name field.

Returns:

  • (type: String)

    the name field



40
# File 'lib/inat/data/entity/taxon.rb', line 40

field :name, type: String, index: true, required: true

#nativetype: Boolean

Returns the native field.

Returns:

  • (type: Boolean)

    the native field



38
# File 'lib/inat/data/entity/taxon.rb', line 38

field :native, type: Boolean

#parenttype: Taxon

Returns the parent field.

Returns:

  • (type: Taxon)

    the parent field



39
# File 'lib/inat/data/entity/taxon.rb', line 39

field :parent, type: Taxon

#photos_lockedtype: Boolean

field :observations_count, type: Integer

Returns:

  • (type: Boolean)

    the photos_locked field



48
# File 'lib/inat/data/entity/taxon.rb', line 48

field :photos_locked, type: Boolean

#preferred_common_nametype: String

field :iconic_taxon, type: Taxon, index: true

Returns:

  • (type: String)

    the preferred_common_name field



54
# File 'lib/inat/data/entity/taxon.rb', line 54

field :preferred_common_name, type: String

#ranktype: Rank

Returns the rank field.

Returns:

  • (type: Rank)

    the rank field



41
# File 'lib/inat/data/entity/taxon.rb', line 41

field :rank, type: Rank, index: true

#rank_leveltype: Float

Returns the rank_level field.

Returns:

  • (type: Float)

    the rank_level field



36
# File 'lib/inat/data/entity/taxon.rb', line 36

field :rank_level, type: Float, index: true

#taxon_changes_counttype: Integer

Returns the taxon_changes_count field.

Returns:

  • (type: Integer)

    the taxon_changes_count field



45
# File 'lib/inat/data/entity/taxon.rb', line 45

field :taxon_changes_count, type: Integer

#taxon_photosArray<item_type: Photo>

Returns the taxon_photos field.

Returns:

  • (Array<item_type: Photo>)

    the taxon_photos field



59
# File 'lib/inat/data/entity/taxon.rb', line 59

links :taxon_photos, item_type: Photo, table_name: :taxon_photos

#taxon_schemes_counttype: Integer

Returns the taxon_schemes_count field.

Returns:

  • (type: Integer)

    the taxon_schemes_count field



46
# File 'lib/inat/data/entity/taxon.rb', line 46

field :taxon_schemes_count, type: Integer

#threatenedtype: Boolean

Returns the threatened field.

Returns:

  • (type: Boolean)

    the threatened field



35
# File 'lib/inat/data/entity/taxon.rb', line 35

field :threatened, type: Boolean, index: true

#visiontype: Boolean

Returns the vision field.

Returns:

  • (type: Boolean)

    the vision field



56
# File 'lib/inat/data/entity/taxon.rb', line 56

field :vision, type: Boolean

#wikipedia_summarytype: String

Returns the wikipedia_summary field.

Returns:

  • (type: String)

    the wikipedia_summary field



51
# File 'lib/inat/data/entity/taxon.rb', line 51

field :wikipedia_summary, type: String

#wikipedia_urltype: URI

field :universal_search_rank, type: Integer

Returns:

  • (type: URI)

    the wikipedia_url field



50
# File 'lib/inat/data/entity/taxon.rb', line 50

field :wikipedia_url, type: URI

Instance Method Details

#===(other) ⇒ Object



82
83
84
# File 'lib/inat/data/entity/taxon.rb', line 82

def === other
  other.id == self.id || other.ancestor_ids.include?(self.id)
end

#prepare_name(name) ⇒ Object (private)



90
91
92
# File 'lib/inat/data/entity/taxon.rb', line 90

private def prepare_name name
  name.downcase.gsub(' ', ' ').capitalize
end

#sort_keyObject



86
87
88
# File 'lib/inat/data/entity/taxon.rb', line 86

def sort_key
  [ iconic_taxon_name || IconicTaxa::UNKNOWN, name ]
end

#to_sObject



94
95
96
97
98
99
100
# File 'lib/inat/data/entity/taxon.rb', line 94

def to_s
  if preferred_common_name
    "<a href=\"https://www.inaturalist.org/taxa/#{ id }\"><i class=\"icon-iconic-#{ (iconic_taxon_name || IconicTaxa::UNKNOWN).to_s.downcase }\" style=\"font-size:1.5em;height:1em;line-height:1em;\"></i> #{ prepare_name(preferred_common_name) } <i>(#{ prepare_name(name) })</i></a>"
  else
    "<a href=\"https://www.inaturalist.org/taxa/#{ id }\"><i class=\"icon-iconic-#{ (iconic_taxon_name || IconicTaxa::UNKNOWN).to_s.downcase }\" style=\"font-size:1.5em;height:1em;line-height:1em;\"></i> <i>#{ prepare_name(name) }</i></a>"
  end
end