wahlrecht_de 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cae48787b15853f85eb1bf49870fc2a93859bed
4
- data.tar.gz: 46128ce6ed248633b91fd7f08aad510ac0357baf
3
+ metadata.gz: 56992d54595138ab2c8a23c2a3a2b218dd6bb533
4
+ data.tar.gz: 00e283c273b816dcf523e39a13feaebef14d72d8
5
5
  SHA512:
6
- metadata.gz: c037d8c4073f8dc09ba555ce3c039377b3765f850bd36ea410465c21dfa6a9d60d857f5448a8f1e957e24e614abcd44a7f6b8986f5a4533d1dd09ffa03d75bbd
7
- data.tar.gz: 4e4af7e8da61ef5c08c6bcaa4a56d66932d3ee8501946703cb6a1b7298e64eb205eccba3f94afb5c9488def349b2f3e190367c695cec439bf25c851d3ad790e2
6
+ metadata.gz: 5d1568b1375ac7862c409900d48ff2987fdfaac0eece9c4d65afd9da95cc25fee0ef46d7cdf8f03168a76b18e41743143832b4445b35d557eaa935e94463e6f4
7
+ data.tar.gz: 17e468ba2ec4bbe8cda087ccec3352225cb7459234d806e7578a9c916a489200453d3f169c0c1c88489812faa463dc24022853b6efb76c29896777643a7beceb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/dataline.rb CHANGED
@@ -1,21 +1,24 @@
1
+ require_relative 'datapoint'
2
+
1
3
  module WahlrechtDe
2
4
  class Dataline
3
5
 
4
- def initialize name, prognosis
5
- @name = name
6
- @prognosis = format_prognosis prognosis
7
- end
8
-
9
- def format_prognosis prognosis
10
- prognosis.pop
11
- prognosis = prognosis - ["", "–"]
12
- prognosis.each do |datapoint| format_datapoint datapoint end
6
+ def initialize row
7
+ @name = row.at_xpath("th/text()").to_s
8
+ @prognosis = parse_rowdata row
13
9
  end
14
10
 
15
- def format_datapoint datapoint
16
- datapoint.sub! ",", "."
17
- datapoint.chomp! " %"
18
- datapoint.chomp! ".0"
11
+ def parse_rowdata row
12
+ row_data = []
13
+ datas = row.xpath("td")
14
+ datas.pop
15
+ datas.each do |data|
16
+ string_data = data.at_xpath("text()").to_s
17
+ unless (string_data == "" or string_data == "–")
18
+ row_data.push Datapoint.new string_data
19
+ end
20
+ end
21
+ row_data
19
22
  end
20
23
 
21
24
  def prognosis_range
data/lib/datapoint.rb ADDED
@@ -0,0 +1,26 @@
1
+ module WahlrechtDe
2
+ class Datapoint
3
+ include Comparable
4
+ attr_reader :content
5
+
6
+ def initialize data
7
+ format_data data
8
+ @content = data
9
+ end
10
+
11
+ def format_data data
12
+ data.sub! ",", "."
13
+ data.chomp! " %"
14
+ data.chomp! ".0"
15
+ end
16
+
17
+ def <=> other
18
+ Float(self.content) <=> Float(other.content)
19
+ end
20
+
21
+ def to_s
22
+ "#{@content}"
23
+ end
24
+
25
+ end
26
+ end
data/lib/survey.rb CHANGED
@@ -15,17 +15,7 @@ module WahlrechtDe
15
15
 
16
16
  def parse index
17
17
  row = @rows[index]
18
- row_data = parse_rowdata row
19
- @datalines.push(Dataline.new(row.at_xpath("th/text()").to_s, row_data))
20
- end
21
-
22
- def parse_rowdata row
23
- row_data = []
24
- datas = row.xpath("td")
25
- datas.each do |data|
26
- row_data.push(data.at_xpath("text()").to_s)
27
- end
28
- row_data
18
+ @datalines.push Dataline.new row
29
19
  end
30
20
 
31
21
  def to_s
data/wahlrecht_de.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wahlrecht_de"
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tobi Fankh\u{e4}nel"]
12
- s.date = "2013-08-28"
12
+ s.date = "2013-09-01"
13
13
  s.description = "= wahlrecht_de\n\nProvides summary analysis of current poll results from wahlrecht.de\n\n== Contributing to wahlrecht_de\n \n* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.\n* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.\n* Fork the project.\n* Start a feature/bugfix branch.\n* Commit and push until you are happy with your contribution.\n* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.\n\n== Copyright\n\nCopyright (c) 2013 Tobi Fankh\u{e4}nel. See LICENSE.txt for\nfurther details.\n\n"
14
14
  s.email = "fank1@gmx.de"
15
15
  s.executables = ["wahlrecht_de"]
@@ -66,6 +66,7 @@ Gem::Specification.new do |s|
66
66
  "doc/rdoc.css",
67
67
  "doc/table_of_contents.html",
68
68
  "lib/dataline.rb",
69
+ "lib/datapoint.rb",
69
70
  "lib/runner.rb",
70
71
  "lib/survey.rb",
71
72
  "spec/dataline_spec.rb",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wahlrecht_de
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
  - Tobi Fankhänel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-28 00:00:00.000000000 Z
11
+ date: 2013-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -175,6 +175,7 @@ files:
175
175
  - doc/rdoc.css
176
176
  - doc/table_of_contents.html
177
177
  - lib/dataline.rb
178
+ - lib/datapoint.rb
178
179
  - lib/runner.rb
179
180
  - lib/survey.rb
180
181
  - spec/dataline_spec.rb