sapor 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sapor/poll.rb +1 -13
  3. data/lib/sapor/regional_data/european_union_austria.rb +1 -1
  4. data/lib/sapor/regional_data/european_union_croatia.rb +1 -1
  5. data/lib/sapor/regional_data/european_union_denmark.rb +1 -1
  6. data/lib/sapor/regional_data/european_union_estonia.rb +1 -1
  7. data/lib/sapor/regional_data/european_union_finland.rb +1 -1
  8. data/lib/sapor/regional_data/european_union_france.rb +1 -1
  9. data/lib/sapor/regional_data/european_union_ireland.rb +2 -2
  10. data/lib/sapor/regional_data/european_union_ireland_with_ia.rb +2 -2
  11. data/lib/sapor/regional_data/european_union_italy.rb +1 -1
  12. data/lib/sapor/regional_data/european_union_netherlands.rb +1 -1
  13. data/lib/sapor/regional_data/european_union_poland.rb +1 -1
  14. data/lib/sapor/regional_data/european_union_spain.rb +1 -1
  15. data/lib/sapor.rb +0 -12
  16. data/sapor.gemspec +1 -1
  17. data/spec/unit/european_union_austria_spec.rb +3 -3
  18. data/spec/unit/european_union_croatia_spec.rb +5 -4
  19. data/spec/unit/european_union_denmark_spec.rb +5 -4
  20. data/spec/unit/european_union_estonia_spec.rb +5 -4
  21. data/spec/unit/european_union_finland_spec.rb +3 -3
  22. data/spec/unit/european_union_france_spec.rb +6 -6
  23. data/spec/unit/european_union_ireland_spec.rb +4 -4
  24. data/spec/unit/european_union_ireland_with_ia_spec.rb +4 -4
  25. data/spec/unit/european_union_italy_spec.rb +5 -5
  26. data/spec/unit/european_union_netherlands_spec.rb +5 -5
  27. data/spec/unit/european_union_poland_spec.rb +3 -3
  28. data/spec/unit/european_union_spain_spec.rb +7 -6
  29. metadata +2 -38
  30. data/lib/sapor/regional_data/european_union_27_austria.rb +0 -76
  31. data/lib/sapor/regional_data/european_union_27_croatia.rb +0 -83
  32. data/lib/sapor/regional_data/european_union_27_denmark.rb +0 -77
  33. data/lib/sapor/regional_data/european_union_27_estonia.rb +0 -74
  34. data/lib/sapor/regional_data/european_union_27_finland.rb +0 -74
  35. data/lib/sapor/regional_data/european_union_27_france.rb +0 -84
  36. data/lib/sapor/regional_data/european_union_27_ireland.rb +0 -96
  37. data/lib/sapor/regional_data/european_union_27_ireland_with_ia.rb +0 -97
  38. data/lib/sapor/regional_data/european_union_27_italy.rb +0 -84
  39. data/lib/sapor/regional_data/european_union_27_netherlands.rb +0 -81
  40. data/lib/sapor/regional_data/european_union_27_poland.rb +0 -84
  41. data/lib/sapor/regional_data/european_union_27_spain.rb +0 -82
  42. data/spec/unit/european_union_27_austria_spec.rb +0 -61
  43. data/spec/unit/european_union_27_croatia_spec.rb +0 -60
  44. data/spec/unit/european_union_27_denmark_spec.rb +0 -62
  45. data/spec/unit/european_union_27_estonia_spec.rb +0 -94
  46. data/spec/unit/european_union_27_finland_spec.rb +0 -75
  47. data/spec/unit/european_union_27_france_spec.rb +0 -73
  48. data/spec/unit/european_union_27_ireland_spec.rb +0 -72
  49. data/spec/unit/european_union_27_ireland_with_ia_spec.rb +0 -74
  50. data/spec/unit/european_union_27_italy_spec.rb +0 -69
  51. data/spec/unit/european_union_27_netherlands_spec.rb +0 -81
  52. data/spec/unit/european_union_27_poland_spec.rb +0 -69
  53. data/spec/unit/european_union_27_spain_spec.rb +0 -130
@@ -1,76 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union (27): Austria.
23
- #
24
- class EuropeanUnion27Austria < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[AT]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Die Grünen–Die Grüne Alternative (Greens/EFA)',
50
- 'JETZT–Liste Pilz (Greens/EFA)'],
51
- ['Freiheitliche Partei Österreichs (ID)'],
52
- ['Meine Stimme Gilt! (*)'],
53
- ['NEOS–Das Neue Österreich und Liberales Forum (RE)'],
54
- ['Österreichische Volkspartei (EPP)'],
55
- ['Sozialdemokratische Partei Österreichs (S&D)']].freeze
56
-
57
- NO_OF_SEATS = 19
58
-
59
- # Voter turnout on 26 May 2019
60
- # Source: Web page with the official results of the elections of 26 May
61
- # 2019, downloaded on 8 June 2019,
62
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Austria
63
- POPULATION_SIZE = 3_834_656
64
-
65
- THRESHOLD = 0.04
66
-
67
- def electoral_system
68
- if @electoral_system.nil?
69
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS,
70
- DhondtDenominators,
71
- THRESHOLD)
72
- end
73
- @electoral_system
74
- end
75
- end
76
- end
@@ -1,83 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union (27): Croatia.
23
- #
24
- class EuropeanUnion27Croatia < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[HR]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Hrvatska demokratska zajednica (EPP)'],
50
- ['Amsterdamska koalicija (RE)',
51
- 'Hrvatska narodna stranka–liberalni demokrati (RE)',
52
- 'Pametno (RE)'],
53
- ['Bandić Milan 365–Stranka rada i solidarnosti (*)',
54
- 'Nezavisna lista Miroslava Škore (*)',
55
- 'Stranka antikorupcije, razvoja i transparentnosti (*)'],
56
- ['Hrvatska konzervativna stranka (ECR)',
57
- 'Hrvatski rast (ECR)', 'Hrvatski suverenisti (ECR)',
58
- 'Most nezavisnih lista (ECR)'],
59
- ['Nezavisna lista Mislava Kolakušića (NI)',
60
- 'Živi zid (NI)'],
61
- ['Neovisni za Hrvatsku (ID)'],
62
- ['Socijaldemokratska partija Hrvatske (S&D)']].freeze
63
-
64
- NO_OF_SEATS = 12
65
-
66
- # Voter turnout on 26 May 2019
67
- # Source: Web page with the official results of the elections of 26 May
68
- # 2019, downloaded on 22 June 2019,
69
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Croatia
70
- POPULATION_SIZE = 1_073_954
71
-
72
- THRESHOLD = 0.05
73
-
74
- def electoral_system
75
- if @electoral_system.nil?
76
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS,
77
- DhondtDenominators,
78
- THRESHOLD)
79
- end
80
- @electoral_system
81
- end
82
- end
83
- end
@@ -1,77 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union 27: Denmark.
23
- #
24
- class EuropeanUnion27Denmark < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[DK]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Alternativet (Greens/EFA)',
50
- 'Socialistisk Folkeparti (Greens/EFA)'],
51
- ['Dansk Folkeparti (ID)'],
52
- ['Det Konservative Folkeparti (EPP)',
53
- 'Kristendemokraterne (EPP)'],
54
- ['Enhedslisten–De Rød-Grønne (GUE/NGL)'],
55
- ['Klaus Riskær Pedersen (*)', 'Nye Borgerlige (*)',
56
- 'Stram Kurs (*)'],
57
- ['Liberal Alliance (RE)', 'Radikale Venstre (RE)',
58
- 'Venstre (RE)'],
59
- ['Socialdemokraterne (S&D)']].freeze
60
-
61
- NO_OF_SEATS = 14
62
-
63
- # Voter turnout on 26 May 2019
64
- # Source: Web page with the official results of the elections of 26 May
65
- # 2019, downloaded on 10 June 2019,
66
- # https://da.wikipedia.org/wiki/Europa-Parlamentsvalget_2019_i_Danmark
67
- POPULATION_SIZE = 2_800_029
68
-
69
- def electoral_system
70
- if @electoral_system.nil?
71
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS, \
72
- DhondtDenominators)
73
- end
74
- @electoral_system
75
- end
76
- end
77
- end
@@ -1,74 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union 27: Estonia.
23
- #
24
- class EuropeanUnion27Estonia < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[EE]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Eesti 200 (RE)', 'Eesti Keskerakond (RE)',
50
- 'Eesti Reformierakond (RE)',
51
- 'Raimond Kaljulaid (RE)'],
52
- ['Eesti Konservatiivne Rahvaerakond (ID)'],
53
- ['Eesti Vabaerakond (*)'],
54
- ['Erakond Eestimaa Rohelised (Greens/EFA)'],
55
- ['Erakond Isamaa (EPP)'],
56
- ['Sotsiaaldemokraatlik Erakond (S&D)']].freeze
57
-
58
- NO_OF_SEATS = 7
59
-
60
- # Voter turnout on 26 May 2019
61
- # Source: Web page with the official results of the elections of 26 May
62
- # 2019, downloaded on 10 June 2019,
63
- # https://de.wikipedia.org/wiki/Europawahl_in_Estland_2019
64
- POPULATION_SIZE = 332_859
65
-
66
- def electoral_system
67
- if @electoral_system.nil?
68
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS, \
69
- DhondtDenominators)
70
- end
71
- @electoral_system
72
- end
73
- end
74
- end
@@ -1,74 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union (27): Finland.
23
- #
24
- class EuropeanUnion27Finland < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[FI]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Kansallinen Kokoomus (EPP)', 'Kristillisdemokraatit (EPP)'],
50
- ['Liike Nyt (NI)'],
51
- ['Perussuomalaiset (ID)'],
52
- ['Sininen tulevaisuus (ECR)'],
53
- ['Suomen Keskusta (RE)', 'Svenska folkpartiet i Finland (RE)'],
54
- ['Suomen Sosialidemokraattinen Puolue (S&D)'],
55
- ['Vasemmistoliitto (GUE/NGL)'],
56
- ['Vihreä liitto (Greens/EFA)']].freeze
57
-
58
- NO_OF_SEATS = 14
59
-
60
- # Voter turnout on 25 May 2014
61
- # Source: Web page with the official results of the elections of 26 May
62
- # 2019, downloaded on 12 June 2019,
63
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Finland
64
- POPULATION_SIZE = 1_830_045
65
-
66
- def electoral_system
67
- if @electoral_system.nil?
68
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS, \
69
- DhondtDenominators)
70
- end
71
- @electoral_system
72
- end
73
- end
74
- end
@@ -1,84 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union: France.
23
- #
24
- class EuropeanUnion27France < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[FR]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- NO_OF_SEATS
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Agir, la droite constructive–Union des démocrates et' \
50
- ' indépendants (RE)',
51
- 'La République en marche–Mouvement démocrate (RE)'],
52
- ['Debout la France (ECR)'],
53
- ['Europe Écologie Les Verts (Greens/EFA)'],
54
- ['Rassemblement national (ID)'],
55
- ['Génération·s, le mouvement (S&D)',
56
- 'Parti socialiste (S&D)'],
57
- ['La France insoumise (GUE/NGL)',
58
- 'Nouveau Parti anticapitaliste (GUE/NGL)',
59
- 'Parti communiste français (GUE/NGL)'],
60
- ['Les Républicains (EPP)'],
61
- ['Les Patriotes (*)', 'Lutte Ouvrière (*)',
62
- 'Mouvement des gilets jaunes (*)', 'Résistons! (*)',
63
- 'Union populaire républicaine (*)']].freeze
64
-
65
- NO_OF_SEATS = 79
66
-
67
- # Voter turnout on 26 May 2019
68
- # Source: Web page with the official results of the elections of 25-26 May
69
- # 2019, downloaded on 30 December 2019,
70
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_France
71
- POPULATION_SIZE = 22_655_174
72
-
73
- THRESHOLD = 0.05
74
-
75
- def electoral_system
76
- if @electoral_system.nil?
77
- @electoral_system = SingleDistrictProportional.new(NO_OF_SEATS,
78
- DhondtDenominators,
79
- THRESHOLD)
80
- end
81
- @electoral_system
82
- end
83
- end
84
- end
@@ -1,96 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union (27): Ireland.
23
- #
24
- class EuropeanUnion27Ireland < Area
25
- include Singleton
26
-
27
- def area_code
28
- 'EU27[IE]'
29
- end
30
-
31
- def coalitions
32
- COALITIONS
33
- end
34
-
35
- def no_of_seats
36
- SEAT_DISTRIBUTION.values.inject(:+)
37
- end
38
-
39
- def population_size
40
- POPULATION_SIZE
41
- end
42
-
43
- def seats(simulation)
44
- electoral_system.project(simulation)
45
- end
46
-
47
- private
48
-
49
- COALITIONS = [['Catholic Democrats (*)', 'Direct Democracy Ireland (*)',
50
- 'Fís Nua (*)', 'Independent Alliance (*)',
51
- 'Independents (*)', 'Renua Ireland (*)'],
52
- ['Fianna Fáil (RE)'],
53
- ['Fine Gael (EPP)'],
54
- ['Green Party (Greens/EFA)'],
55
- ['Independents 4 Change (GUE/NGL)', 'Sinn Féin (GUE/NGL)',
56
- 'Socialist Party (GUE/NGL)',
57
- 'Solidarity–People Before Profit (GUE/NGL)'],
58
- ['Labour Party (S&D)', 'Social Democrats (S&D)']].freeze
59
-
60
- # Voter turnout on 24 May 2019
61
- # Source: Web page with the official results of the elections of 24 May
62
- # 2019, downloaded on 23 June 2019,
63
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Ireland
64
- POPULATION_SIZE = 1_678_003
65
-
66
- SEAT_DISTRIBUTION = { 'Dublin' => 4, 'Midlands–North-West' => 4,
67
- 'South' => 5 }
68
-
69
- def election_results_of_2019
70
- if @election_results_of_2019.nil?
71
- @election_results_of_2019 = load_election_results( \
72
- 'european-union-ireland-20190524.psv')
73
- end
74
- @election_results_of_2019
75
- end
76
-
77
- def electoral_system
78
- if @electoral_system.nil?
79
- @electoral_system = MultiDistrictProportional.new( \
80
- overall_election_results_of_2019,
81
- election_results_of_2019,
82
- SEAT_DISTRIBUTION,
83
- DhondtDenominators)
84
- end
85
- @electoral_system
86
- end
87
-
88
- def overall_election_results_of_2019
89
- if @overall_election_results_of_2019.nil?
90
- @overall_election_results_of_2019 = \
91
- summarize_election_results(election_results_of_2019)
92
- end
93
- @overall_election_results_of_2019
94
- end
95
- end
96
- end
@@ -1,97 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Statistical Analysis of Polling Results (SAPoR)
4
- # Copyright (C) 2020 Filip van Laenen <f.a.vanlaenen@ieee.org>
5
- #
6
- # This file is part of SAPoR.
7
- #
8
- # SAPoR is free software: you can redistribute it and/or modify it under the
9
- # terms of the GNU General Public License as published by the Free Software
10
- # Foundation, either version 3 of the License, or (at your option) any later
11
- # version.
12
- #
13
- # SAPoR is distributed in the hope that it will be useful, but WITHOUT ANY
14
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
- # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
- #
17
- # You can find a copy of the GNU General Public License in /doc/gpl.txt
18
- #
19
-
20
- module Sapor
21
- #
22
- # The regional data for the European Union (27): Ireland, with Independent
23
- # Alliance (IA).
24
- #
25
- class EuropeanUnion27IrelandWithIa < Area
26
- include Singleton
27
-
28
- def area_code
29
- 'EU27[IE]∪{IA}'
30
- end
31
-
32
- def coalitions
33
- COALITIONS
34
- end
35
-
36
- def no_of_seats
37
- SEAT_DISTRIBUTION.values.inject(:+)
38
- end
39
-
40
- def population_size
41
- POPULATION_SIZE
42
- end
43
-
44
- def seats(simulation)
45
- electoral_system.project(simulation)
46
- end
47
-
48
- private
49
-
50
- COALITIONS = [['Catholic Democrats (*)', 'Direct Democracy Ireland (*)',
51
- 'Fís Nua (*)', 'Independent Alliance (*)',
52
- 'Independents (*)', 'Renua Ireland (*)'],
53
- ['Fianna Fáil (RE)'],
54
- ['Fine Gael (EPP)'],
55
- ['Green Party (Greens/EFA)'],
56
- ['Independents 4 Change (GUE/NGL)', 'Sinn Féin (GUE/NGL)',
57
- 'Socialist Party (GUE/NGL)',
58
- 'Solidarity–People Before Profit (GUE/NGL)'],
59
- ['Labour Party (S&D)', 'Social Democrats (S&D)']].freeze
60
-
61
- # Voter turnout on 24 May 2019
62
- # Source: Web page with the official results of the elections of 24 May
63
- # 2019, downloaded on 23 June 2019,
64
- # https://en.wikipedia.org/wiki/2019_European_Parliament_election_in_Ireland
65
- POPULATION_SIZE = 1_678_003
66
-
67
- SEAT_DISTRIBUTION = { 'Dublin' => 4, 'Midlands–North-West' => 4,
68
- 'South' => 5 }
69
-
70
- def election_results_of_2019
71
- if @election_results_of_2019.nil?
72
- @election_results_of_2019 = load_election_results( \
73
- 'european-union-ireland-20190524-ia.psv')
74
- end
75
- @election_results_of_2019
76
- end
77
-
78
- def electoral_system
79
- if @electoral_system.nil?
80
- @electoral_system = MultiDistrictProportional.new( \
81
- overall_election_results_of_2019,
82
- election_results_of_2019,
83
- SEAT_DISTRIBUTION,
84
- DhondtDenominators)
85
- end
86
- @electoral_system
87
- end
88
-
89
- def overall_election_results_of_2019
90
- if @overall_election_results_of_2019.nil?
91
- @overall_election_results_of_2019 = \
92
- summarize_election_results(election_results_of_2019)
93
- end
94
- @overall_election_results_of_2019
95
- end
96
- end
97
- end