Sha256: de713b616010fd09fceb3ff95ef1b1d1aa3c0876ff7964518bad63287b9d12f4
Contents?: true
Size: 1.1 KB
Versions: 67
Compression:
Stored size: 1.1 KB
Contents
require 'digest/md5' module SpatialFeatures module Importers class Base attr_reader :errors def initialize(data, make_valid: false) @make_valid = make_valid @data = data @errors = [] end def features @features ||= build_features end def cache_key @cache_key ||= Digest::MD5.hexdigest(@data) end private def build_features new_features = [] each_record do |record| begin new_features << build_feature(record) rescue => e @errors << e.message end end return new_features end def each_record(&block) raise NotImplementedError, 'Subclasses should implement this method and yield objects that can be passed to #build_feature' end def build_feature(record) Feature.new(:name => record.name, :metadata => record.metadata, :feature_type => record.feature_type, :geog => record.geog, :make_valid => @make_valid) end end end # EXCEPTIONS class ImportError < StandardError; end end
Version data entries
67 entries across 67 versions & 1 rubygems