compass_point 1.0.1 → 1.0.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
  SHA1:
3
- metadata.gz: 8e46d4553f9de5ae11fab63be88ffea5b32b21b1
4
- data.tar.gz: 9103ff880351b8f3469e912d27fcd351dc9b34e5
3
+ metadata.gz: 4d27d02b07168d627ee4693a4c45dfad6c75018e
4
+ data.tar.gz: bde7020da857168654bf795ca9b5d7efe8dadbef
5
5
  SHA512:
6
- metadata.gz: 3060a1b29300b947838f00e6d4083f0985b11bbc90b16c0840addf77bd83f4e2e58c205708cbe4e3e551bb91aa78788bb2090bb25057e49935ac06cb8dc64f85
7
- data.tar.gz: 03e91329bc09f28df2bff07a1584fbbe1f5b1cbe4fa422d9a966bd03c0d7e76aad81071df579abde78ac300875ec1f8b453ce97c30adcf2e0c9fc04c1f5387e8
6
+ metadata.gz: 3815565ac48ea00489dab98374a778f2c70795d7dcd36cf551e975c9d7a4b10525796dae4c2d062526da6620a921cdee54657537a8ef6b1da143bb0b4afa87d1
7
+ data.tar.gz: 418f6e1ff33779b84c25d961bd81bb31a8cd56fa22bb52af4ad09e8d841668464021f6d06455526abc757f1ed01aa81247b1e329ac33d8a9211699a359be7974
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- compass_point (1.0.0)
4
+ compass_point (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -42,6 +42,11 @@ abbreviation with `min`, `max` and `min_max`:
42
42
  CompassPoint.max('E') #=> 95.62
43
43
  CompassPoint.min_max('E') #=> [84.38, 95.62]
44
44
 
45
+ Get the full name for an abbreviation:
46
+
47
+ CompassPoint.name('NNW') #=> "North northwest"
48
+ CompassPoint.name('SEbS') #=> "Southeast by south"
49
+
45
50
 
46
51
  ## License
47
52
 
data/lib/compass_point.rb CHANGED
@@ -1,73 +1,76 @@
1
1
  class CompassPoint
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
 
4
4
  POINTS = {
5
- n: {min: 354.38, mid: 0.0, max: 5.62},
6
- nbe: {min: 5.63, mid: 11.25, max: 16.87},
7
- nne: {min: 16.88, mid: 22.5, max: 28.12},
8
- nebn: {min: 28.13, mid: 33.75, max: 39.37},
9
- ne: {min: 39.38, mid: 45.0, max: 50.62},
10
- nebe: {min: 50.63, mid: 56.25, max: 61.87},
11
- ene: {min: 61.88, mid: 67.5, max: 73.12},
12
- ebn: {min: 73.13, mid: 78.75, max: 84.37},
13
- e: {min: 84.38, mid: 90.0, max: 95.62},
14
- ebs: {min: 95.63, mid: 101.25, max: 106.87},
15
- ese: {min: 106.88, mid: 112.5, max: 118.12},
16
- sebe: {min: 118.13, mid: 123.75, max: 129.37},
17
- se: {min: 129.38, mid: 135.0, max: 140.62},
18
- sebs: {min: 140.63, mid: 146.25, max: 151.87},
19
- sse: {min: 151.88, mid: 157.5, max: 163.12},
20
- sbe: {min: 163.13, mid: 168.75, max: 174.37},
21
- s: {min: 174.38, mid: 180.0, max: 185.62},
22
- sbw: {min: 185.63, mid: 191.25, max: 196.87},
23
- ssw: {min: 196.88, mid: 202.5, max: 208.12},
24
- swbs: {min: 208.13, mid: 213.75, max: 219.37},
25
- sw: {min: 219.38, mid: 225.0, max: 230.62},
26
- swbw: {min: 230.63, mid: 236.25, max: 241.87},
27
- wsw: {min: 241.88, mid: 247.5, max: 253.12},
28
- wbs: {min: 253.13, mid: 258.75, max: 264.37},
29
- w: {min: 264.38, mid: 270.0, max: 275.62},
30
- wbn: {min: 275.63, mid: 281.25, max: 286.87},
31
- wnw: {min: 286.88, mid: 292.5, max: 298.12},
32
- nwbw: {min: 298.13, mid: 303.75, max: 309.37},
33
- nw: {min: 309.38, mid: 315.0, max: 320.62},
34
- nwbn: {min: 320.63, mid: 326.25, max: 331.87},
35
- nnw: {min: 331.88, mid: 337.50, max: 343.12},
36
- nbw: {min: 343.13, mid: 348.75, max: 354.37}
5
+ n: {min: 354.38, mid: 0.0, max: 5.62, name: 'North'},
6
+ nbe: {min: 5.63, mid: 11.25, max: 16.87, name: 'North by east'},
7
+ nne: {min: 16.88, mid: 22.5, max: 28.12, name: 'North-northeast'},
8
+ nebn: {min: 28.13, mid: 33.75, max: 39.37, name: 'Northeast by north'},
9
+ ne: {min: 39.38, mid: 45.0, max: 50.62, name: 'Northeast'},
10
+ nebe: {min: 50.63, mid: 56.25, max: 61.87, name: 'Northeast by east'},
11
+ ene: {min: 61.88, mid: 67.5, max: 73.12, name: 'East-northeast'},
12
+ ebn: {min: 73.13, mid: 78.75, max: 84.37, name: 'East by north'},
13
+ e: {min: 84.38, mid: 90.0, max: 95.62, name: 'East'},
14
+ ebs: {min: 95.63, mid: 101.25, max: 106.87, name: 'East by south'},
15
+ ese: {min: 106.88, mid: 112.5, max: 118.12, name: 'East-southeast'},
16
+ sebe: {min: 118.13, mid: 123.75, max: 129.37, name: 'Southeast by east'},
17
+ se: {min: 129.38, mid: 135.0, max: 140.62, name: 'Southeast'},
18
+ sebs: {min: 140.63, mid: 146.25, max: 151.87, name: 'Southeast by south'},
19
+ sse: {min: 151.88, mid: 157.5, max: 163.12, name: 'South-southeast'},
20
+ sbe: {min: 163.13, mid: 168.75, max: 174.37, name: 'South by east'},
21
+ s: {min: 174.38, mid: 180.0, max: 185.62, name: 'South'},
22
+ sbw: {min: 185.63, mid: 191.25, max: 196.87, name: 'South by west'},
23
+ ssw: {min: 196.88, mid: 202.5, max: 208.12, name: 'South southwest'},
24
+ swbs: {min: 208.13, mid: 213.75, max: 219.37, name: 'Southwest by south'},
25
+ sw: {min: 219.38, mid: 225.0, max: 230.62, name: 'Southwest'},
26
+ swbw: {min: 230.63, mid: 236.25, max: 241.87, name: 'Southwest by west'},
27
+ wsw: {min: 241.88, mid: 247.5, max: 253.12, name: 'West-southwest'},
28
+ wbs: {min: 253.13, mid: 258.75, max: 264.37, name: 'West by south'},
29
+ w: {min: 264.38, mid: 270.0, max: 275.62, name: 'West'},
30
+ wbn: {min: 275.63, mid: 281.25, max: 286.87, name: 'West by north'},
31
+ wnw: {min: 286.88, mid: 292.5, max: 298.12, name: 'West-northwest'},
32
+ nwbw: {min: 298.13, mid: 303.75, max: 309.37, name: 'Northwest by west'},
33
+ nw: {min: 309.38, mid: 315.0, max: 320.62, name: 'Northwest'},
34
+ nwbn: {min: 320.63, mid: 326.25, max: 331.87, name: 'Northwest by north'},
35
+ nnw: {min: 331.88, mid: 337.50, max: 343.12, name: 'North northwest'},
36
+ nbw: {min: 343.13, mid: 348.75, max: 354.37, name: 'North by west'}
37
37
  }
38
38
 
39
39
  class << self
40
- def azimuth(abbreviation)
41
- key = normalize_abbreviation(abbreviation)
42
- point = POINTS[key]
40
+ def azimuth(abbrev)
41
+ point = find_point(abbrev)
43
42
  point && point[:mid]
44
43
  end
45
44
 
46
- def min(abbreviation)
47
- key = normalize_abbreviation(abbreviation)
48
- point = POINTS[key]
45
+ def min(abbrev)
46
+ point = find_point(abbrev)
49
47
  point && point[:min]
50
48
  end
51
49
 
52
- def max(abbreviation)
53
- key = normalize_abbreviation(abbreviation)
54
- point = POINTS[key]
50
+ def max(abbrev)
51
+ point = find_point(abbrev)
55
52
  point && point[:max]
56
53
  end
57
54
 
58
- def min_max(abbreviation)
59
- key = normalize_abbreviation(abbreviation)
60
- point = POINTS[key]
55
+ def min_max(abbrev)
56
+ point = find_point(abbrev)
61
57
  point && [point[:min], point[:max]]
62
58
  end
63
59
 
64
- private
65
-
66
- def normalize_abbreviation(compass_point)
67
- compass_point.to_s.downcase.to_sym
60
+ def name(abbrev)
61
+ point = find_point(abbrev)
62
+ point && point[:name]
68
63
  end
69
- end
70
64
 
65
+ private
71
66
 
67
+ def find_point(abbrev)
68
+ key = normalize_abbrev(abbrev)
69
+ POINTS[key]
70
+ end
72
71
 
72
+ def normalize_abbrev(abbrev)
73
+ abbrev.to_s.downcase.to_sym
74
+ end
75
+ end
73
76
  end
@@ -37,4 +37,10 @@ describe CompassPoint do
37
37
  end
38
38
  end
39
39
 
40
+ describe '.name' do
41
+ it 'returns the points full name' do
42
+ expect(CompassPoint.name('nnw')).to eq 'North northwest'
43
+ end
44
+ end
45
+
40
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass_point
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Morrison
@@ -25,7 +25,6 @@ files:
25
25
  - LICENSE
26
26
  - README.md
27
27
  - Rakefile
28
- - compass_point-1.0.0.gem
29
28
  - compass_point.gemspec
30
29
  - lib/compass_point.rb
31
30
  - spec/compass_point_spec.rb
Binary file