national_grid 0.1.2 → 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: 8f41ecc57f8f9a7908bd0a4c0850bea186060eb1
4
- data.tar.gz: 3db89a1bb90c25dd163d8cb3aaca85e5173c6ad9
3
+ metadata.gz: 8ec0e110d4ad5b1c699d302874a93102a9d49f1d
4
+ data.tar.gz: 3bbd7e3972857d902d3915ce503a37f5f21b3228
5
5
  SHA512:
6
- metadata.gz: b4f670c8624ce08e88170b9034625b2b6825a9084670d4743a5be1cfbd03acae012a7d9a9b50ce6730cfec87eca49f1323c1d9e20b2fc028c5509e08b23910d3
7
- data.tar.gz: b6ad55bbbf7e5cf61a51af91d3b86ee93ebb6f95d30583b3a35811bc1a43fc2ede6b167bf929575ca16add6de57a0d1ae032567a97f9150a8fbd09911f846396
6
+ metadata.gz: 034ffa69b41306e1998688c295c84b127c29b5b670baa012221f63b972fab0b9fb6d837d620cc5856b6cedaf8d28fac7bcee64b28d701ca64b52e8190b38b64a
7
+ data.tar.gz: a2b1a2b9c4d25129c544835a692daaa64ef1ab361b219ead423e36344bc50689e5cf44d8a0c2e83fd03618ce6e81d3ff586f652dd816870a61c954beb48db7fa
@@ -1,5 +1,6 @@
1
1
  require "national_grid/version"
2
2
  require "national_grid/national_grid"
3
3
  require "national_grid/inspect"
4
+ require "national_grid/round"
4
5
  require "national_grid/easting_northing"
5
6
  require "national_grid/latitude_longitude"
@@ -1,6 +1,7 @@
1
1
  module NationalGrid
2
2
  class EastingNorthing
3
3
  include Inspect
4
+ include Round
4
5
 
5
6
  def to_a
6
7
  [easting, northing, elevation]
@@ -1,6 +1,7 @@
1
1
  module NationalGrid
2
2
  class LatitudeLongitude
3
3
  include Inspect
4
+ include Round
4
5
 
5
6
  def to_a
6
7
  [latitude, longitude, elevation]
@@ -0,0 +1,7 @@
1
+ module NationalGrid
2
+ module Round
3
+ def round(decimal_places = 0)
4
+ self.class.new(*to_a.map {|ordinate| ordinate.round(decimal_places)})
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module NationalGrid
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -43,6 +43,14 @@ module NationalGrid
43
43
  assert_nil EastingNorthing.new(999999.999, 999999.999, 99.999).to_latitude_longitude
44
44
  end
45
45
 
46
+ def test_round
47
+ point = EastingNorthing.new(12.3456, 78.9012, 34.5678).round(3)
48
+
49
+ assert_equal 12.346, point.easting
50
+ assert_equal 78.901, point.northing
51
+ assert_equal 34.568, point.elevation
52
+ end
53
+
46
54
  private
47
55
 
48
56
  def assert_close(expected, actual)
@@ -43,6 +43,14 @@ module NationalGrid
43
43
  assert_nil LatitudeLongitude.new(-45.878761, 170.502798).to_easting_northing
44
44
  end
45
45
 
46
+ def test_round
47
+ point = LatitudeLongitude.new(12.3456, 78.9012, 34.5678).round(3)
48
+
49
+ assert_equal 12.346, point.latitude
50
+ assert_equal 78.901, point.longitude
51
+ assert_equal 34.568, point.elevation
52
+ end
53
+
46
54
  private
47
55
 
48
56
  def assert_close(expected, actual)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: national_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Haines
@@ -113,6 +113,7 @@ files:
113
113
  - lib/national_grid/easting_northing.rb
114
114
  - lib/national_grid/inspect.rb
115
115
  - lib/national_grid/latitude_longitude.rb
116
+ - lib/national_grid/round.rb
116
117
  - lib/national_grid/version.rb
117
118
  - national_grid.gemspec
118
119
  - test/national_grid/easting_northing_test.rb