silva 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,5 +3,5 @@ module Silva
3
3
  class InvalidTransformError < StandardError; end
4
4
  class InvalidParamError < StandardError; end
5
5
  class InvalidParamValueError < StandardError; end
6
- class InsufficentParamsError < StandardError; end
6
+ class InsufficientParamsError < StandardError; end
7
7
  end
@@ -30,7 +30,7 @@ module Silva
30
30
  #
31
31
  def initialize(options)
32
32
  @system_name = self.class.name.split('::').last.downcase.to_sym
33
- options = DEFAULT_PARAMS.merge(options)
33
+ options = self.class::DEFAULT_PARAMS.merge(options)
34
34
  params_satisfied?(options)
35
35
  options.each {|param, val| set_param(param, val) }
36
36
  end
@@ -61,7 +61,7 @@ module Silva
61
61
  end
62
62
 
63
63
  def params_satisfied?(options)
64
- raise InsufficientParamsError unless REQUIRED_PARAMS & options.keys == REQUIRED_PARAMS
64
+ raise Silva::InsufficientParamsError unless self.class::REQUIRED_PARAMS & options.keys == self.class::REQUIRED_PARAMS
65
65
  end
66
66
  end
67
67
  end
@@ -28,8 +28,6 @@ module Silva
28
28
  # Height of the UK grid
29
29
  OSGB_GRID_SCALE = 100000
30
30
 
31
- attr_reader :gridref
32
-
33
31
  ##
34
32
  # Lazily create the gridref from given eastings and northings, or just return it if already set.
35
33
  #
@@ -37,14 +35,14 @@ module Silva
37
35
  #
38
36
  def gridref
39
37
  unless @gridref
40
- e100k = (@easting / 100000).floor
41
- n100k = (@northing / 100000).floor
38
+ e100k = (easting / 100000).floor
39
+ n100k = (northing / 100000).floor
42
40
 
43
41
  index = n100k * OSGB_GRID_WIDTH + e100k
44
42
  prefix = OSGB_PREFIXES[index]
45
43
 
46
- e = ((@easting % OSGB_GRID_SCALE) / (10**(5 - @digits / 2))).round
47
- n = ((@northing % OSGB_GRID_SCALE) / (10**(5 - @digits / 2))).round
44
+ e = ((easting % OSGB_GRID_SCALE) / (10**(5 - @digits / 2))).round
45
+ n = ((northing % OSGB_GRID_SCALE) / (10**(5 - @digits / 2))).round
48
46
 
49
47
  @gridref = prefix + e.to_s.rjust(@digits / 2) + n.to_s.rjust(@digits / 2)
50
48
  end
@@ -98,7 +96,7 @@ module Silva
98
96
  end
99
97
 
100
98
  def params_satisfied?(options)
101
- super or options.include?(:gridref)
99
+ super unless options.include?(:gridref)
102
100
  end
103
101
  end
104
102
  end
data/lib/silva/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Silva
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/test/test_gridref.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  class TestGridref < Test::Unit::TestCase
2
- def test_gridref_to_s
2
+ def test_gridref_no_digits
3
3
  Silva::Test::DATA.each do |data|
4
- options = { :gridref => data[:gridref], :digits => 8 }
5
- l = Silva::Location.from(:gridref, options)
4
+ l = Silva::Location.from(:en, data[:en]).to(:gridref)
6
5
  assert_equal(data[:gridref], l.to_s)
7
6
  end
8
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: silva
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: