swiss-village-directory 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,10 +6,26 @@ module SwissVillageDirectory
6
6
  attr_reader :villages
7
7
 
8
8
  def initialize
9
- raw_data = CSV.read('data/PLZO_CSV_WGS84.csv', col_sep: ';')
9
+ raw_data = CSV.read(File.dirname(__FILE__) + '/../../data/PLZO_CSV_WGS84.csv', col_sep: ';')
10
10
  @villages = raw_data[1..-1].map do |row|
11
11
  Village.new(row[0], row[1], row[2], row[3], row[4], row[5], row[6])
12
12
  end
13
13
  end
14
+
15
+ def find_all_by(find_params)
16
+ @villages.find_all { |v| all_filters_matched?(v, find_params) }
17
+ end
18
+
19
+ private
20
+
21
+ def all_filters_matched?(village, filter_params)
22
+ filter_params.each do |p|
23
+ return false if filter_matches?(village, p.first, p.last)
24
+ end
25
+ end
26
+
27
+ def filter_matches?(village, key, value)
28
+ village.instance_variable_get("@#{key}") != value
29
+ end
14
30
  end
15
31
  end
@@ -1,3 +1,3 @@
1
1
  module SwissVillageDirectory
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -6,8 +6,8 @@ require 'swiss_village_directory/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'swiss-village-directory'
8
8
  spec.version = SwissVillageDirectory::VERSION
9
- spec.authors = ['Josua Schmid']
10
- spec.email = ['josua.schmid@renuo.ch']
9
+ spec.authors = ['Josua Schmid', 'Simon Huber']
10
+ spec.email = ['josua.schmid@renuo.ch', 'simon.huber@renuo.ch']
11
11
 
12
12
  spec.summary = 'This gem provides a data set of all swiss villages taken out of the "Ortschaftenverzeichnis" (https://data.geo.admin.ch/ch.swisstopo-vd.ortschaftenverzeichnis_plz/readme.txt)'
13
13
  spec.homepage = 'https://github.com/renuo/swiss-village-directory'
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiss-village-directory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josua Schmid
8
+ - Simon Huber
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2016-07-06 00:00:00.000000000 Z
12
+ date: 2016-07-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -83,6 +84,7 @@ dependencies:
83
84
  description:
84
85
  email:
85
86
  - josua.schmid@renuo.ch
87
+ - simon.huber@renuo.ch
86
88
  executables: []
87
89
  extensions: []
88
90
  extra_rdoc_files: []
@@ -125,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
127
  version: '0'
126
128
  requirements: []
127
129
  rubyforge_project:
128
- rubygems_version: 2.5.1
130
+ rubygems_version: 2.4.5.1
129
131
  signing_key:
130
132
  specification_version: 4
131
133
  summary: This gem provides a data set of all swiss villages taken out of the "Ortschaftenverzeichnis"