Class: INat::Entity::Place
- Inherits:
-
Data::Entity
- Object
- Data::Model
- Data::Entity
- INat::Entity::Place
- Extended by:
- BySLUG
- Includes:
- Data::Types, INat::Entity
- Defined in:
- lib/inat/data/entity/place.rb
Fields collapse
-
#admin_level ⇒ type: Integer
The
admin_level
field. -
#ancestor_places ⇒ Array<item_type: Place>
The
ancestor_places
field. -
#bbox_area ⇒ type: Float
The
bbox_area
field. -
#display_name ⇒ type: String
The
display_name
field. -
#location ⇒ type: Location
The
location
field. -
#name ⇒ type: String
The
name
field. -
#place_type ⇒ type: Integer
The
place_type
field. -
#slug ⇒ type: Symbol
The
slug
field. -
#uuid ⇒ type: UUID
The
uuid
field.
Attributes inherited from Data::Entity
Class Method Summary collapse
Instance Method Summary collapse
Methods included from BySLUG
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
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
#admin_level ⇒ type: Integer
Returns the admin_level
field.
32 |
# File 'lib/inat/data/entity/place.rb', line 32 field :admin_level, type: Integer, index: true |
#ancestor_places ⇒ Array<item_type: Place>
Returns the ancestor_places
field.
39 |
# File 'lib/inat/data/entity/place.rb', line 39 links :ancestor_places, item_type: Place, table_name: :place_ancestors, link_field: :ancestor_id, index: true |
#bbox_area ⇒ type: Float
Returns the bbox_area
field.
31 |
# File 'lib/inat/data/entity/place.rb', line 31 field :bbox_area, type: Float |
#display_name ⇒ type: String
Returns the display_name
field.
30 |
# File 'lib/inat/data/entity/place.rb', line 30 field :display_name, type: String, index: true |
#location ⇒ type: Location
Returns the location
field.
34 |
# File 'lib/inat/data/entity/place.rb', line 34 field :location, type: Location |
#name ⇒ type: String
Returns the name
field.
28 |
# File 'lib/inat/data/entity/place.rb', line 28 field :name, type: String, index: true, required: true |
#place_type ⇒ type: Integer
Returns the place_type
field.
33 |
# File 'lib/inat/data/entity/place.rb', line 33 field :place_type, type: Integer, index: true |
#slug ⇒ type: Symbol
Returns the slug
field.
29 |
# File 'lib/inat/data/entity/place.rb', line 29 field :slug, type: Symbol, index: true |
Class Method Details
.DDL ⇒ Object
53 54 55 56 57 58 |
# File 'lib/inat/data/entity/place.rb', line 53 def DDL super + "INSERT OR REPLACE INTO places (id, uuid, name, display_name) VALUES (59614, '00000000-0000-0000-0000-000000000000', 'World', 'Весь мир');\n" # Если верить API, то идентификатор такой есть, а записи для него нет. # Вставляем ему искусственно некоторые данные для того, чтобы не запрашивать впустую каждый раз, как он встречается. end |
Instance Method Details
#===(other) ⇒ Object
43 44 45 |
# File 'lib/inat/data/entity/place.rb', line 43 def === other self.id == other.id && other.ancestor_place_ids.include?(self.id) end |
#sort_key ⇒ Object
47 48 49 |
# File 'lib/inat/data/entity/place.rb', line 47 def sort_key display_name end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/inat/data/entity/place.rb', line 62 def to_s "<a href=\"https://www.inaturalist.org/places/#{ id }\"><i class=\"fa fa-globe\"></i> #{ display_name || name }</a>" end |