Sha256: bbb26c2046a99edb942bcb660dbb87747a7b6a2e55218449c95ce5d1a2d35c4b

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

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

  def self.find_all_by_province_id(province_id)
    return [] if province_id.blank?

    collection_klass.records.select{ |place| place.province_id == province_id }
  end

  private

  def self.collection_klass
    INE::Places::PlacesCollection
  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.province.slug }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ine-places-0.1.0 lib/ine/places/place.rb