Sha256: 66335942d617f0de87e3f9e43b3c627b7e728a973c11bb98c70bcb3ff54528e2

Contents?: true

Size: 746 Bytes

Versions: 13

Compression:

Stored size: 746 Bytes

Contents

class INE::Places::Province < OpenStruct
  include INE::Places::CSVRecord

  def self.find_all_by_autonomous_region_id(autonomous_region_id)
    raise ArgumentError if autonomous_region_id.blank?

    collection_klass.records.select{|province| province.autonomous_region_id == autonomous_region_id }
  end

  def places
    INE::Places::Place.find_all_by_province_id(self.id)
  end

  private

  def self.collection_klass
    INE::Places::ProvincesCollection
  end

  def self.filter(records, name)
    return [] if name.blank?
    parameterized_name = name.parameterize

    records.select{|p| p.slug.include?(parameterized_name) }.
      reject{|p| ['ceuta','melilla'].include?(p.slug) }.
      sort_by{|p| p.autonomous_region.slug }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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