Class: INat::Entity::Place

Inherits:
Data::Entity show all
Extended by:
BySLUG
Includes:
Data::Types, INat::Entity
Defined in:
lib/inat/data/entity/place.rb

Fields collapse

Attributes inherited from Data::Entity

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BySLUG

by_slug

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_leveltype: Integer

Returns the admin_level field.

Returns:

  • (type: Integer)

    the admin_level field



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

field :admin_level, type: Integer, index: true

#ancestor_placesArray<item_type: Place>

Returns the ancestor_places field.

Returns:

  • (Array<item_type: Place>)

    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_areatype: Float

Returns the bbox_area field.

Returns:

  • (type: Float)

    the bbox_area field



31
# File 'lib/inat/data/entity/place.rb', line 31

field :bbox_area, type: Float

#display_nametype: String

Returns the display_name field.

Returns:

  • (type: String)

    the display_name field



30
# File 'lib/inat/data/entity/place.rb', line 30

field :display_name, type: String, index: true

#locationtype: Location

Returns the location field.

Returns:

  • (type: Location)

    the location field



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

field :location, type: Location

#nametype: String

Returns the name field.

Returns:

  • (type: String)

    the name field



28
# File 'lib/inat/data/entity/place.rb', line 28

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

#place_typetype: Integer

Returns the place_type field.

Returns:

  • (type: Integer)

    the place_type field



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

field :place_type, type: Integer, index: true

#slugtype: Symbol

Returns the slug field.

Returns:

  • (type: Symbol)

    the slug field



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

field :slug, type: Symbol, index: true

#uuidtype: UUID

Returns the uuid field.

Returns:

  • (type: UUID)

    the uuid field



27
# File 'lib/inat/data/entity/place.rb', line 27

field :uuid, type: UUID, unique: true

Class Method Details

.DDLObject



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_keyObject



47
48
49
# File 'lib/inat/data/entity/place.rb', line 47

def sort_key
  display_name
end

#to_sObject



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