Class: INat::Entity::Observation
- Inherits:
-
Data::Entity
- Object
- Data::Model
- Data::Entity
- INat::Entity::Observation
- Includes:
- Data::Types, INat::Entity
- Defined in:
- lib/inat/data/entity/observation.rb
Fields collapse
-
#cached_projects ⇒ Array<item_type: Project>
The
cached_projects
field. -
#captive ⇒ type: Boolean
The
captive
field. -
#comments ⇒ Array<item_type: Comment>
The
comments
field. -
#community_taxon ⇒ type: Taxon
The
community_taxon
field. -
#created_at ⇒ type: Time
The
created_at
field. -
#day ⇒ type: Integer
The
day
field. -
#description ⇒ type: String
The
description
field. -
#endemic ⇒ type: Boolean
The
endemic
field. -
#faves ⇒ Array<item_type: Vote>
The
faves
field. -
#flags ⇒ Array<item_type: Flag>
The
flags
field. -
#geoprivacy ⇒ type: GeoPrivacy
The
geoprivacy
field. -
#ident_taxa ⇒ Array<item_type: Taxon>
The
ident_taxa
field. -
#identifications ⇒ Array<item_type: Identification>
The
identifications
field. -
#identifications_most_agree ⇒ type: Boolean
The
identifications_most_agree
field. -
#identifications_most_disagree ⇒ type: Boolean
The
identifications_most_disagree
field. -
#identifications_some_agree ⇒ type: Boolean
The
identifications_some_agree
field. -
#introduced ⇒ type: Boolean
The
introduced
field. -
#license_code ⇒ type: LicenseCode
The
license_code
field. -
#location ⇒ type: Location
The
location
field. -
#mappable ⇒ type: Boolean
The
mappable
field. -
#month ⇒ type: Integer
The
month
field. -
#native ⇒ type: Boolean
The
native
field. -
#num_identification_agreements ⇒ type: Integer
The
num_identification_agreements
field. -
#num_identification_disagreements ⇒ type: Integer
The
num_identification_disagreements
field. -
#obscured ⇒ type: Boolean
The
obscured
field. -
#observation_photos ⇒ Array<item_type: ObservationPhoto>
The
observation_photos
field. -
#observation_sounds ⇒ Array<item_type: ObservationSound>
The
observation_sounds
field. -
#observed_on ⇒ type: Date
The
observed_on
field. -
#observed_on_details ⇒ type: Object
writeonly
The
observed_on_details
field. -
#observed_on_string ⇒ type: String
The
observed_on_string
field. -
#owners_identification_from_vision ⇒ type: Boolean
The
owners_identification_from_vision
field. -
#photo_licensed ⇒ type: Boolean
The
photo_licensed
field. -
#photos ⇒ Array<item_type: Photo>
The
photos
field. -
#place_guess ⇒ type: String
The
place_guess
field. -
#places ⇒ Array<item_type: Place>
The
places
field. -
#positional_accuracy ⇒ type: Integer
The
positional_accuracy
field. -
#projects ⇒ Array<item_type: Project>
Это только ручные.
-
#public_positional_accuracy ⇒ type: Integer
The
public_positional_accuracy
field. -
#quality_grade ⇒ type: QualityGrade
The
quality_grade
field. -
#rank ⇒ type: Rank
The
rank
field. -
#sounds ⇒ Array<item_type: Sound>
The
sounds
field. -
#spam ⇒ type: Boolean
The
spam
field. -
#species_guess ⇒ type: String
The
species_guess
field. -
#taxon ⇒ type: Taxon
The
taxon
field. -
#taxon_geoprivacy ⇒ type: GeoPrivacy
The
taxon_geoprivacy
field. -
#taxon_is_active ⇒ type: Boolean
The
taxon_is_active
field. -
#threatened ⇒ type: Boolean
The
threatened
field. -
#time_observed_at ⇒ type: Time
The
time_observed_at
field. -
#updated_at ⇒ type: Time
The
updated_at
field. -
#uri ⇒ type: URI
The
uri
field. -
#user ⇒ type: User
The
user
field. -
#uuid ⇒ type: UUID
The
uuid
field. -
#votes ⇒ Array<item_type: Vote>
The
votes
field. -
#year ⇒ type: Integer
The
year
field.
Attributes inherited from Data::Entity
Callbacks collapse
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, #process?, #saved?, table, #to_h, #update
Constructor Details
This class inherits a constructor from INat::Data::Entity
Instance Attribute Details
#cached_projects ⇒ Array<item_type: Project>
Returns the cached_projects
field.
75 |
# File 'lib/inat/data/entity/observation.rb', line 75 links :cached_projects, item_type: Project, table_name: :project_observations, owned: false |
#captive ⇒ type: Boolean
Returns the captive
field.
44 |
# File 'lib/inat/data/entity/observation.rb', line 44 field :captive, type: Boolean, index: true |
#comments ⇒ Array<item_type: Comment>
Returns the comments
field.
83 |
# File 'lib/inat/data/entity/observation.rb', line 83 backs :comments, item_type: Comment, owned: true |
#community_taxon ⇒ type: Taxon
Returns the community_taxon
field.
46 |
# File 'lib/inat/data/entity/observation.rb', line 46 field :community_taxon, type: Taxon, index: true |
#created_at ⇒ type: Time
Returns the created_at
field.
56 |
# File 'lib/inat/data/entity/observation.rb', line 56 field :created_at, type: Time, index: true |
#day ⇒ type: Integer
Returns the day
field.
91 |
# File 'lib/inat/data/entity/observation.rb', line 91 field :day, type: Integer, index: true |
#description ⇒ type: String
Returns the description
field.
43 |
# File 'lib/inat/data/entity/observation.rb', line 43 field :description, type: String |
#endemic ⇒ type: Boolean
Returns the endemic
field.
103 |
# File 'lib/inat/data/entity/observation.rb', line 103 field :endemic, type: Boolean, index: true |
#faves ⇒ Array<item_type: Vote>
Returns the faves
field.
89 |
# File 'lib/inat/data/entity/observation.rb', line 89 links :faves, item_type: Vote, owned: true |
#flags ⇒ Array<item_type: Flag>
Returns the flags
field.
53 |
# File 'lib/inat/data/entity/observation.rb', line 53 links :flags, item_type: Flag, owned: true |
#geoprivacy ⇒ type: GeoPrivacy
Returns the geoprivacy
field.
61 |
# File 'lib/inat/data/entity/observation.rb', line 61 field :geoprivacy, type: GeoPrivacy, index: true |
#ident_taxa ⇒ Array<item_type: Taxon>
Returns the ident_taxa
field.
86 |
# File 'lib/inat/data/entity/observation.rb', line 86 links :ident_taxa, item_type: Taxon, ids_field: :ident_taxon_ids, index: true, owned: true |
#identifications ⇒ Array<item_type: Identification>
Returns the identifications
field.
84 |
# File 'lib/inat/data/entity/observation.rb', line 84 backs :identifications, item_type: Identification, owned: true |
#identifications_most_agree ⇒ type: Boolean
Returns the identifications_most_agree
field.
78 |
# File 'lib/inat/data/entity/observation.rb', line 78 field :identifications_most_agree, type: Boolean |
#identifications_most_disagree ⇒ type: Boolean
Returns the identifications_most_disagree
field.
81 |
# File 'lib/inat/data/entity/observation.rb', line 81 field :identifications_most_disagree, type: Boolean |
#identifications_some_agree ⇒ type: Boolean
Returns the identifications_some_agree
field.
79 |
# File 'lib/inat/data/entity/observation.rb', line 79 field :identifications_some_agree, type: Boolean |
#introduced ⇒ type: Boolean
Returns the introduced
field.
104 |
# File 'lib/inat/data/entity/observation.rb', line 104 field :introduced, type: Boolean, index: true |
#license_code ⇒ type: LicenseCode
Returns the license_code
field.
42 |
# File 'lib/inat/data/entity/observation.rb', line 42 field :license_code, type: LicenseCode, index: true |
#location ⇒ type: Location
Returns the location
field.
63 |
# File 'lib/inat/data/entity/observation.rb', line 63 field :location, type: Location, index: true |
#mappable ⇒ type: Boolean
Returns the mappable
field.
51 |
# File 'lib/inat/data/entity/observation.rb', line 51 field :mappable, type: Boolean, index: true |
#month ⇒ type: Integer
Returns the month
field.
92 |
# File 'lib/inat/data/entity/observation.rb', line 92 field :month, type: Integer, index: true |
#native ⇒ type: Boolean
Returns the native
field.
105 |
# File 'lib/inat/data/entity/observation.rb', line 105 field :native, type: Boolean, index: true |
#num_identification_agreements ⇒ type: Integer
Returns the num_identification_agreements
field.
80 |
# File 'lib/inat/data/entity/observation.rb', line 80 field :num_identification_agreements, type: Integer |
#num_identification_disagreements ⇒ type: Integer
Returns the num_identification_disagreements
field.
82 |
# File 'lib/inat/data/entity/observation.rb', line 82 field :num_identification_disagreements, type: Integer |
#obscured ⇒ type: Boolean
Returns the obscured
field.
48 |
# File 'lib/inat/data/entity/observation.rb', line 48 field :obscured, type: Boolean, index: true |
#observation_photos ⇒ Array<item_type: ObservationPhoto>
Returns the observation_photos
field.
70 |
# File 'lib/inat/data/entity/observation.rb', line 70 backs :observation_photos, item_type: ObservationPhoto, owned: true |
#observation_sounds ⇒ Array<item_type: ObservationSound>
Returns the observation_sounds
field.
68 |
# File 'lib/inat/data/entity/observation.rb', line 68 backs :observation_sounds, item_type: ObservationSound, owned: true |
#observed_on ⇒ type: Date
Returns the observed_on
field.
57 |
# File 'lib/inat/data/entity/observation.rb', line 57 field :observed_on, type: Date, index: true |
#observed_on_details=(value) ⇒ type: Object (writeonly)
Returns the observed_on_details
field.
95 96 97 98 99 100 101 |
# File 'lib/inat/data/entity/observation.rb', line 95 block :observed_on_details, type: Object do |value| if Hash === value self.day = value['day'] self.month = value['month'] self.year = value['year'] end end |
#observed_on_string ⇒ type: String
Returns the observed_on_string
field.
58 |
# File 'lib/inat/data/entity/observation.rb', line 58 field :observed_on_string, type: String |
#owners_identification_from_vision ⇒ type: Boolean
Returns the owners_identification_from_vision
field.
77 |
# File 'lib/inat/data/entity/observation.rb', line 77 field :owners_identification_from_vision, type: Boolean |
#photo_licensed ⇒ type: Boolean
Returns the photo_licensed
field.
108 |
# File 'lib/inat/data/entity/observation.rb', line 108 field :photo_licensed, type: Boolean, index: true |
#photos ⇒ Array<item_type: Photo>
Returns the photos
field.
71 |
# File 'lib/inat/data/entity/observation.rb', line 71 links :photos, item_type: Photo, table_name: :observation_photos, owned: false |
#place_guess ⇒ type: String
Returns the place_guess
field.
66 |
# File 'lib/inat/data/entity/observation.rb', line 66 field :place_guess, type: String |
#places ⇒ Array<item_type: Place>
Returns the places
field.
73 |
# File 'lib/inat/data/entity/observation.rb', line 73 links :places, item_type: Place, owned: true |
#positional_accuracy ⇒ type: Integer
Returns the positional_accuracy
field.
64 |
# File 'lib/inat/data/entity/observation.rb', line 64 field :positional_accuracy, type: Integer, index: true |
#projects ⇒ Array<item_type: Project>
Это только ручные
74 |
# File 'lib/inat/data/entity/observation.rb', line 74 links :projects, item_type: Project, owned: true |
#public_positional_accuracy ⇒ type: Integer
Returns the public_positional_accuracy
field.
65 |
# File 'lib/inat/data/entity/observation.rb', line 65 field :public_positional_accuracy, type: Integer, index: true |
#quality_grade ⇒ type: QualityGrade
Returns the quality_grade
field.
39 |
# File 'lib/inat/data/entity/observation.rb', line 39 field :quality_grade, type: QualityGrade, required: true, index: true |
#rank ⇒ type: Rank
Returns the rank
field.
109 |
# File 'lib/inat/data/entity/observation.rb', line 109 field :rank, type: Rank, index: true |
#sounds ⇒ Array<item_type: Sound>
Returns the sounds
field.
69 |
# File 'lib/inat/data/entity/observation.rb', line 69 links :sounds, item_type: Sound, table_name: :observation_sounds, owned: false |
#spam ⇒ type: Boolean
Returns the spam
field.
49 |
# File 'lib/inat/data/entity/observation.rb', line 49 field :spam, type: Boolean, index: true |
#species_guess ⇒ type: String
Returns the species_guess
field.
41 |
# File 'lib/inat/data/entity/observation.rb', line 41 field :species_guess, type: String |
#taxon ⇒ type: Taxon
Returns the taxon
field.
45 |
# File 'lib/inat/data/entity/observation.rb', line 45 field :taxon, type: Taxon, index: true |
#taxon_geoprivacy ⇒ type: GeoPrivacy
Returns the taxon_geoprivacy
field.
62 |
# File 'lib/inat/data/entity/observation.rb', line 62 field :taxon_geoprivacy, type: GeoPrivacy, index: true |
#taxon_is_active ⇒ type: Boolean
Returns the taxon_is_active
field.
106 |
# File 'lib/inat/data/entity/observation.rb', line 106 field :taxon_is_active, type: Boolean, index: true |
#threatened ⇒ type: Boolean
Returns the threatened
field.
107 |
# File 'lib/inat/data/entity/observation.rb', line 107 field :threatened, type: Boolean, index: true |
#time_observed_at ⇒ type: Time
Returns the time_observed_at
field.
55 |
# File 'lib/inat/data/entity/observation.rb', line 55 field :time_observed_at, type: Time, index: true |
#updated_at ⇒ type: Time
Returns the updated_at
field.
59 |
# File 'lib/inat/data/entity/observation.rb', line 59 field :updated_at, type: Time, index: true |
#uri ⇒ type: URI
Returns the uri
field.
47 |
# File 'lib/inat/data/entity/observation.rb', line 47 field :uri, type: URI |
#user ⇒ type: User
Returns the user
field.
50 |
# File 'lib/inat/data/entity/observation.rb', line 50 field :user, type: User, index: true |
#uuid ⇒ type: UUID
Returns the uuid
field.
40 |
# File 'lib/inat/data/entity/observation.rb', line 40 field :uuid, type: UUID, unique: true |
#votes ⇒ Array<item_type: Vote>
Returns the votes
field.
88 |
# File 'lib/inat/data/entity/observation.rb', line 88 links :votes, item_type: Vote, owned: true |
#year ⇒ type: Integer
Returns the year
field.
93 |
# File 'lib/inat/data/entity/observation.rb', line 93 field :year, type: Integer, index: true |
Instance Method Details
#normalized_taxon(ranks) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/inat/data/entity/observation.rb', line 132 def normalized_taxon ranks ranks = (ranks .. ranks) if Rank === ranks raise TypeError, "Invalid type for ranks: #{ ranks.inspect }!", caller unless Range === ranks min = ranks.begin # max = ranks.end taxon = self.taxon while true do return nil if taxon == nil return nil if taxon.rank < min return taxon if ranks === taxon.rank taxon = taxon.parent end end |
#post_update ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/inat/data/entity/observation.rb', line 115 def post_update t = self.taxon if t self.endemic = t.endemic self.introduced = t.introduced self.native = t.native self.taxon_is_active = t.is_active self.threatened = t.threatened self.rank = t.rank end if self.observation_photos != nil self.photo_licensed = self.observation_photos.any? { |p| p.photo.license_code != nil } end end |
#sort_key ⇒ Object
146 147 148 |
# File 'lib/inat/data/entity/observation.rb', line 146 def sort_key time_observed_at || observed_on&.to_time || Time::at(0) end |
#to_s ⇒ Object
181 182 183 |
# File 'lib/inat/data/entity/observation.rb', line 181 def to_s "<a href=\"https://www.inaturalist.org/observations/#{ id }\">\##{ id }</a>" end |