compass_point 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/compass_point.rb +5 -7
- data/spec/compass_point_spec.rb +51 -52
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58dc6a0e428a79c4f324f8203b4bd263b79e83a2bc27ed2b9275d737579f5b49
|
4
|
+
data.tar.gz: 6f7747c5f2298d8801a6f4c28636237c5ced151c5439826ec6db0aaa92cd5e14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1afe4228022af269623dcdf5d0918ae87bd805773d6b08f1bc043197cc6d8b45c4bb7e569f56717b2ae3c42dcd861f7113c8d46d7bac1546155e10e0bc0a72b4
|
7
|
+
data.tar.gz: 6222b9724ca875db38cd2cf2213e53233463ce9e02cef98ee5664211bbc3212769bd4e25c524b0485380b798999a7b6c7563948508fa077ce5b71fa2a6c547ed
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ A Ruby library for working with compass points.
|
|
16
16
|
|
17
17
|
Compass Point is compatible with the following versions of Ruby:
|
18
18
|
|
19
|
-
* MRI Ruby 3.
|
19
|
+
* MRI Ruby 3.1.x, 3.2.x, and 3.3.x
|
20
20
|
|
21
21
|
## Installation
|
22
22
|
|
@@ -68,7 +68,7 @@ example:
|
|
68
68
|
|
69
69
|
## License
|
70
70
|
|
71
|
-
Copyright (c) 2015-
|
71
|
+
Copyright (c) 2015-2024 Keith Morrison <<keithm@infused.org>>
|
72
72
|
|
73
73
|
Permission is hereby granted, free of charge, to any person
|
74
74
|
obtaining a copy of this software and associated documentation
|
data/lib/compass_point.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class CompassPoint
|
2
|
-
VERSION = '
|
2
|
+
VERSION = '3.0.0'.freeze
|
3
3
|
|
4
|
-
COMPASS_BEARING_REGEX = /(n|s)\s(\d{1,3}).?\s(e|w)
|
4
|
+
COMPASS_BEARING_REGEX = /(n|s)\s(\d{1,3}).?\s(e|w)/
|
5
5
|
|
6
6
|
POINTS = {
|
7
7
|
n: {min: 354.38, mid: 0.0, max: 5.62, name: 'North'},
|
@@ -41,9 +41,9 @@ class CompassPoint
|
|
41
41
|
class << self
|
42
42
|
def azimuth(s)
|
43
43
|
input = normalize_input(s)
|
44
|
-
if point = find_point(input)
|
44
|
+
if (point = find_point(input))
|
45
45
|
point[:mid]
|
46
|
-
elsif match = input.match(COMPASS_BEARING_REGEX)
|
46
|
+
elsif (match = input.match(COMPASS_BEARING_REGEX))
|
47
47
|
azimuth_from_match(match)
|
48
48
|
end
|
49
49
|
end
|
@@ -96,15 +96,13 @@ class CompassPoint
|
|
96
96
|
180
|
97
97
|
end
|
98
98
|
|
99
|
-
adjust = match[2].to_i
|
100
|
-
|
101
99
|
operation = if (match[1] == 'n' && match[3] == 'w') || (match[1] == 's' && match[3] == 'e')
|
102
100
|
:-
|
103
101
|
else
|
104
102
|
:+
|
105
103
|
end
|
106
104
|
|
107
|
-
base.send(operation,
|
105
|
+
base.send(operation, match[2].to_i)
|
108
106
|
end
|
109
107
|
|
110
108
|
def generate_compass_quadrant_bearing(b)
|
data/spec/compass_point_spec.rb
CHANGED
@@ -3,88 +3,87 @@ require 'spec_helper'
|
|
3
3
|
describe CompassPoint do
|
4
4
|
describe '.azimuth' do
|
5
5
|
it 'returns mid point in degrees' do
|
6
|
-
expect(
|
7
|
-
expect(
|
8
|
-
expect(
|
9
|
-
expect(
|
10
|
-
expect(
|
11
|
-
expect(
|
12
|
-
expect(
|
13
|
-
expect(
|
14
|
-
expect(
|
15
|
-
expect(
|
16
|
-
expect(
|
6
|
+
expect(described_class.azimuth('N')).to eq 0.0
|
7
|
+
expect(described_class.azimuth(:nw)).to eq 315.0
|
8
|
+
expect(described_class.azimuth('sbw')).to eq 191.25
|
9
|
+
expect(described_class.azimuth('X')).to be_nil
|
10
|
+
expect(described_class.azimuth('Northeast by east')).to eq 56.25
|
11
|
+
expect(described_class.azimuth('N 27° E')).to eq 27
|
12
|
+
expect(described_class.azimuth('S 77° E')).to eq 103
|
13
|
+
expect(described_class.azimuth('S 2° E')).to eq 178
|
14
|
+
expect(described_class.azimuth('N 77° W')).to eq 283
|
15
|
+
expect(described_class.azimuth('N 20 W')).to eq 340
|
16
|
+
expect(described_class.azimuth('S 30° W')).to eq 210
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '.back_azimuth' do
|
21
21
|
it 'returns opposite of azimuth' do
|
22
|
-
expect(
|
23
|
-
expect(
|
24
|
-
expect(
|
25
|
-
expect(
|
26
|
-
expect(
|
27
|
-
expect(
|
28
|
-
expect(
|
29
|
-
expect(
|
30
|
-
expect(
|
31
|
-
expect(
|
32
|
-
expect(
|
22
|
+
expect(described_class.back_azimuth('N')).to eq 180.0
|
23
|
+
expect(described_class.back_azimuth(:nw)).to eq 135.0
|
24
|
+
expect(described_class.back_azimuth('sbw')).to eq 11.25
|
25
|
+
expect(described_class.back_azimuth('X')).to be_nil
|
26
|
+
expect(described_class.back_azimuth('Northeast by east')).to eq 236.25
|
27
|
+
expect(described_class.back_azimuth('N 27° E')).to eq 207
|
28
|
+
expect(described_class.back_azimuth('S 77° E')).to eq 283
|
29
|
+
expect(described_class.back_azimuth('S 2° E')).to eq 358
|
30
|
+
expect(described_class.back_azimuth('N 77° W')).to eq 103
|
31
|
+
expect(described_class.back_azimuth('N 20 W')).to eq 160
|
32
|
+
expect(described_class.back_azimuth('S 30° W')).to eq 30
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '.min' do
|
37
37
|
it 'returns min point in degrees' do
|
38
|
-
expect(
|
39
|
-
expect(
|
40
|
-
expect(
|
41
|
-
expect(
|
42
|
-
expect(
|
38
|
+
expect(described_class.min('N')).to eq 354.38
|
39
|
+
expect(described_class.min(:nw)).to eq 309.38
|
40
|
+
expect(described_class.min('sbw')).to eq 185.63
|
41
|
+
expect(described_class.min('X')).to be_nil
|
42
|
+
expect(described_class.min('Northeast by east')).to eq 50.63
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '.max' do
|
47
47
|
it 'returns max point in degrees' do
|
48
|
-
expect(
|
49
|
-
expect(
|
50
|
-
expect(
|
51
|
-
expect(
|
52
|
-
expect(
|
48
|
+
expect(described_class.max('N')).to eq 5.62
|
49
|
+
expect(described_class.max(:nw)).to eq 320.62
|
50
|
+
expect(described_class.max('sbw')).to eq 196.87
|
51
|
+
expect(described_class.max('X')).to be_nil
|
52
|
+
expect(described_class.max('Northeast by east')).to eq 61.87
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe '.min_max' do
|
57
57
|
it 'returns [min, max]' do
|
58
|
-
expect(
|
59
|
-
expect(
|
60
|
-
expect(
|
61
|
-
expect(
|
62
|
-
expect(
|
58
|
+
expect(described_class.min_max('N')).to eq [354.38, 5.62]
|
59
|
+
expect(described_class.min_max(:nw)).to eq [309.38, 320.62]
|
60
|
+
expect(described_class.min_max('sbw')).to eq [185.63, 196.87]
|
61
|
+
expect(described_class.min_max('X')).to be_nil
|
62
|
+
expect(described_class.min_max('Northeast by east')).to eq [50.63, 61.87]
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe '.name' do
|
67
67
|
it 'returns the points full name' do
|
68
|
-
expect(
|
68
|
+
expect(described_class.name('nnw')).to eq 'North northwest'
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
describe '.compass_quadrant_bearing' do
|
73
73
|
it 'is' do
|
74
|
-
expect(
|
75
|
-
expect(
|
76
|
-
expect(
|
77
|
-
expect(
|
78
|
-
expect(
|
79
|
-
expect(
|
80
|
-
expect(
|
81
|
-
expect(
|
82
|
-
expect(
|
83
|
-
expect(
|
84
|
-
expect(
|
85
|
-
expect(
|
86
|
-
expect(
|
74
|
+
expect(described_class.compass_quadrant_bearing(0)).to eq 'N'
|
75
|
+
expect(described_class.compass_quadrant_bearing(27)).to eq 'N 27° E'
|
76
|
+
expect(described_class.compass_quadrant_bearing(27.4)).to eq 'N 27° E'
|
77
|
+
expect(described_class.compass_quadrant_bearing(27.7)).to eq 'N 28° E'
|
78
|
+
expect(described_class.compass_quadrant_bearing(90)).to eq 'E'
|
79
|
+
expect(described_class.compass_quadrant_bearing(103)).to eq 'S 77° E'
|
80
|
+
expect(described_class.compass_quadrant_bearing(178)).to eq 'S 2° E'
|
81
|
+
expect(described_class.compass_quadrant_bearing(180)).to eq 'S'
|
82
|
+
expect(described_class.compass_quadrant_bearing(210)).to eq 'S 30° W'
|
83
|
+
expect(described_class.compass_quadrant_bearing(270)).to eq 'W'
|
84
|
+
expect(described_class.compass_quadrant_bearing(283)).to eq 'N 77° W'
|
85
|
+
expect(described_class.compass_quadrant_bearing(340)).to eq 'N 20° W'
|
86
|
+
expect(described_class.compass_quadrant_bearing(360)).to eq 'N'
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
90
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compass_point
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby library for working with compass points
|
14
14
|
email: keithm@infused.org
|
@@ -37,14 +37,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.
|
40
|
+
version: 3.1.0
|
41
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
|
-
rubygems_version: 3.
|
47
|
+
rubygems_version: 3.5.3
|
48
48
|
signing_key:
|
49
49
|
specification_version: 4
|
50
50
|
summary: A Ruby library for working with compass points
|