Class: SpatialFeatures::Importers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/spatial_features/importers/base.rb

Direct Known Subclasses

GeoJSON, KML, Shapefile

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, make_valid: false, tmpdir: nil, source_identifier: nil, feature_name: ->(record) { record.name }) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
# File 'lib/spatial_features/importers/base.rb', line 9

def initialize(data, make_valid: false, tmpdir: nil, source_identifier: nil, feature_name: ->(record) { record.name })
  @make_valid = make_valid
  @data = data
  @errors = []
  @tmpdir = tmpdir
  @source_identifier = source_identifier
  @feature_name = feature_name
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/spatial_features/importers/base.rb', line 6

def errors
  @errors
end

#source_identifierObject

An identifier for the source of the features. Used to differentiate groups of features on the spatial model.



7
8
9
# File 'lib/spatial_features/importers/base.rb', line 7

def source_identifier
  @source_identifier
end

Class Method Details

.create_all(data, **options) ⇒ Object

factory method that should always be used instead of ‘new` when creating importers returns an array of Importer::* objects



28
29
30
# File 'lib/spatial_features/importers/base.rb', line 28

def self.create_all(data, **options)
  [new(data, **options)]
end

Instance Method Details

#cache_keyObject



22
23
24
# File 'lib/spatial_features/importers/base.rb', line 22

def cache_key
  @cache_key ||= Digest::MD5.hexdigest(@data)
end

#featuresObject



18
19
20
# File 'lib/spatial_features/importers/base.rb', line 18

def features
  @features ||= build_features
end