cpr-client 0.0.6 → 0.0.7

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: 2a78908818428f7a3b27ebd88c72e3537017cadf
4
- data.tar.gz: c985dd242c57a4f05310fff7e7dac085a9babc60
3
+ metadata.gz: ab8c7d4ff27eab71f8a508a70ea5e82f74930fff
4
+ data.tar.gz: 5d35cf5c9e06f9159635bb46c0a28ce3f0cbad2b
5
5
  SHA512:
6
- metadata.gz: e81272abfb112667cafd1c03df30600fdc999791411aa983f3b557a5d29b71aa5d8080ff5f06e432ce874779a46c01f1a5215c43d893a7c5626e432b3252a49c
7
- data.tar.gz: 4d788c44e214ee4801f02cb3476eaa581785345428eef9b1ba8fa27849848f239572c36fcf2f7b71e3b4331ec078591ce64efe71481cc783f7121b834a30eade
6
+ metadata.gz: 782553d02d2cd44b8191df7623e49aef74a2e8abde9962b1b62db495180ce221583373c98b772e2afde401cdcc9067fc45f789d58b8b45a32003243f865b7b45
7
+ data.tar.gz: 9a0c7c4ef012d018decb90773bd5d2e194e6f1e5b41295f4f7139ec320559ec0ffd2715900a88bb47a172bb8b32ad985a542aed3ac201dcd996339e0885682b7
@@ -41,16 +41,31 @@ module CPRClient
41
41
  # The address will be a string of the fields
42
42
  # STADR, POSTNR and POSTNR's t attribute.
43
43
  #
44
- # Fx. Boulevarden 101,1 mf, 6800 Varde
44
+ # Fx. Boulevarden 101, 1. mf, 6800 Varde
45
45
  #
46
46
  # @return string with address or nil
47
47
  def address
48
- values = [ get(:stadr), get(:postnr), get(:postnr, :t) ]
49
- '%s, %s %s' % values if values.all?
48
+ street_and_number = "#{get(:vejkod, :t)} #{get_clean(:husnr)}"
49
+ postal_district = "#{get(:postnr)} #{get(:postnr, :t)}"
50
+ door = get_clean(:sidedoer)
51
+ floor = get_clean(:etage)
52
+
53
+ if floor and door
54
+ "#{street_and_number}, #{floor}. #{door}, #{postal_district}"
55
+ elsif floor
56
+ "#{street_and_number}, #{floor}., #{postal_district}"
57
+ else
58
+ "#{street_and_number}, #{postal_district}"
59
+ end
50
60
  end
51
61
 
52
62
  private
53
63
 
64
+ def get_clean(name, value = 'v')
65
+ value = get(name, value)
66
+ value.sub(/^[ 0\-]*(.*?)\s*/, '\1') if value
67
+ end
68
+
54
69
  def extract_fields(xml_doc)
55
70
  Hash[xml_doc.css("Praes[r='STAMPNR'] Field").reduce([]) { |a, f|
56
71
  attrs = Hash[f.keys.zip(f.values)]
@@ -1,3 +1,3 @@
1
1
  module CPRClient
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpr-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Andersen
@@ -98,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.4.5.1
101
+ rubygems_version: 2.6.13
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: CPR Client
105
105
  test_files: []
106
- has_rdoc: