compass_point 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/compass_point.rb +53 -50
- data/spec/compass_point_spec.rb +6 -0
- metadata +1 -2
- data/compass_point-1.0.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d27d02b07168d627ee4693a4c45dfad6c75018e
|
4
|
+
data.tar.gz: bde7020da857168654bf795ca9b5d7efe8dadbef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3815565ac48ea00489dab98374a778f2c70795d7dcd36cf551e975c9d7a4b10525796dae4c2d062526da6620a921cdee54657537a8ef6b1da143bb0b4afa87d1
|
7
|
+
data.tar.gz: 418f6e1ff33779b84c25d961bd81bb31a8cd56fa22bb52af4ad09e8d841668464021f6d06455526abc757f1ed01aa81247b1e329ac33d8a9211699a359be7974
|
data/Gemfile.lock
CHANGED
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.
|
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(
|
41
|
-
|
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(
|
47
|
-
|
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(
|
53
|
-
|
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(
|
59
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
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
|
data/spec/compass_point_spec.rb
CHANGED
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.
|
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
|
data/compass_point-1.0.0.gem
DELETED
Binary file
|