Sha256: c2d8c8a387d9662af8d23d468c6d7c2b99d8e84dd7979cd64f79188041a41d14

Contents?: true

Size: 626 Bytes

Versions: 12

Compression:

Stored size: 626 Bytes

Contents

class INE::Places::ProvincesCollection
  include Singleton

  def self.records
    @records ||= CSV.read("#{INE::Places::ROOT}/data/provinces.csv", headers: true).map do |raw_data|
                   build_from_raw_data(raw_data)
                 end.sort_by(&:slug)
  end

  def self.build_from_raw_data(raw_data)
    INE::Places::Province.new({
      id: raw_data[0], name: raw_data[2],
      slug: raw_data[3], autonomous_region_id: raw_data[1],
      lon: raw_data[4], lat: raw_data[5],
      autonomous_region: INE::Places::AutonomousRegion.find(raw_data[1])
    })
  end
  private_class_method :build_from_raw_data

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ine-places-0.5.0 lib/ine/places/provinces_collection.rb
ine-places-0.4.0 lib/ine/places/provinces_collection.rb
ine-places-0.3.0 lib/ine/places/provinces_collection.rb
ine-places-0.2.0 lib/ine/places/provinces_collection.rb
ine-places-0.1.7 lib/ine/places/provinces_collection.rb
ine-places-0.1.6 lib/ine/places/provinces_collection.rb
ine-places-0.1.5 lib/ine/places/provinces_collection.rb
ine-places-0.1.4 lib/ine/places/provinces_collection.rb
ine-places-0.1.3 lib/ine/places/provinces_collection.rb
ine-places-0.1.2 lib/ine/places/provinces_collection.rb
ine-places-0.1.1 lib/ine/places/provinces_collection.rb
ine-places-0.1.0 lib/ine/places/provinces_collection.rb