gps_unit_conversion 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: a623949a7d33be59a9622b8b8fda18eb2c9b576c05c7b54488a4c974e8a20298
4
- data.tar.gz: 8dc26382a7542cf1b269c44329a13c6c995b614ed9c0e3d52fd1353e91bb0bf0
3
+ metadata.gz: d16dd1f0f2586ad60b3727db529554c366557363f2378fa58878d581cea9d757
4
+ data.tar.gz: 749a94a17b2fad0e94a939120c0423eeb5feb54a496f011d02e2afd2a7eead73
5
5
  SHA512:
6
- metadata.gz: fc2e544c212a4510fe0e260139bd86dec1dec834a2db6393003e8dd795551e96f45946bb86fc7992d4f68e9a12dad850bdf3fc78a3c22dd82cc9b57dbdec965a
7
- data.tar.gz: d3ee3e0c139bf2ab80f881cf1020b55c3ee7c0dbbb12b06c6626b0aca4fc3eedcadd66cb2975723d63367dffa5252e142230d482e944a5788ef486be97ffbe77
6
+ metadata.gz: 4e4762bb355b933b6f9c15ae37c737c011f13778dbe4380d70076a981b2e58c3b40126dbc858988a77454f77962262d7a41565c593f5ecd09dd7ce21169848e4
7
+ data.tar.gz: ce37935bbc3a9fb349752f7db914509ae7763252dee5fb33a4b99ec8f00d4e738773753ef0e70710f94c69c43ed87bf1c8e4a4cfc1bb9cc8ad9df901183f9b0d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gps_unit_conversion (0.1.0)
4
+ gps_unit_conversion (0.1.1)
5
5
  activesupport (~> 7.0)
6
6
 
7
7
  GEM
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'gps_unit_conversion'
5
- s.version = '0.1.1'
5
+ s.version = '0.1.2'
6
6
  s.summary = 'Converts longitude and latitude minutes/decimals values'
7
7
  s.description = 'Converts longitude and latitude minutes/decimals values'
8
8
  s.authors = ['Stanislaw Zawadzki']
@@ -29,8 +29,8 @@ module GpsUnitConversion
29
29
  end
30
30
 
31
31
  def seconds
32
- s_value = value[4..-1]
33
- value[4..-1].to_f / 10 ** ((s_value.size - 2).to_i).to_f
32
+ base = value[4..-1]
33
+ base.length > 2 ? base.insert(2, '.').to_f : base.to_f
34
34
  end
35
35
  end
36
36
  end
@@ -16,21 +16,20 @@ module GpsUnitConversion
16
16
  private
17
17
 
18
18
  def value
19
- numbers = longitude.gsub(/\D/, "")
20
- @value ||= numbers[0] == '0' ? numbers[1..-1] : numbers
19
+ @value ||= longitude.gsub(/\D/, "")
21
20
  end
22
21
 
23
22
  def degrees
24
- value[0..1].to_i
23
+ value[0..2].to_i
25
24
  end
26
25
 
27
26
  def minutes
28
- value[2..3].to_i
27
+ value[3..4].to_i
29
28
  end
30
29
 
31
30
  def seconds
32
- s_value = value[4..-1]
33
- value[4..-1].to_f / 10 ** ((s_value.size - 2).to_i).to_f
31
+ base = value[5..-1]
32
+ base.length > 2 ? base.insert(2, '.').to_f : base.to_f
34
33
  end
35
34
  end
36
35
  end
@@ -7,6 +7,26 @@ RSpec.describe GpsUnitConversion::MinutesToDecimal::Latitude do
7
7
  expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 53.81205
8
8
  end
9
9
 
10
+ it 'converts latitude with mored digits' do
11
+ latitude_with_minutes = '5348.43380000'
12
+
13
+ expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 53.81205
14
+ end
15
+
16
+ it 'more examples' do
17
+ latitude_with_minutes = '434343.3416'
18
+ expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 43.728706
19
+
20
+ latitude_with_minutes = '115900.1234'
21
+ expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 11.983368
22
+
23
+ latitude_with_minutes = '811112.0006'
24
+ expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 81.186667
25
+
26
+ latitude_with_minutes = '295423.8926'
27
+ expect(described_class.new(latitude: latitude_with_minutes).convert).to eq 29.906637
28
+ end
29
+
10
30
  it 'converts on southern hemisphere' do
11
31
  latitude_with_minutes = '5348.4338'
12
32
 
@@ -7,6 +7,17 @@ RSpec.describe GpsUnitConversion::MinutesToDecimal::Longitude do
7
7
  expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 20.578047
8
8
  end
9
9
 
10
+ it 'more examples' do
11
+ longitude_with_minutes = '0120050.8824'
12
+ expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 12.014134
13
+
14
+ longitude_with_minutes = '0695959.5959'
15
+ expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 69.999888
16
+
17
+ longitude_with_minutes = '1125612.3972'
18
+ expect(described_class.new(longitude: longitude_with_minutes).convert).to eq 112.936777
19
+ end
20
+
10
21
  it 'converts on western hemisphere' do
11
22
  longitude_with_minutes = '02034.4097'
12
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gps_unit_conversion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislaw Zawadzki