geo_position 0.0.5 → 0.0.6
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.
- data/README.md +13 -6
- data/lib/geo_position/conversion/dms.rb +2 -2
- data/lib/geo_position/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -24,13 +24,23 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
I prefer smaller components that can be put together in different ways.
|
26
26
|
|
27
|
+
Currently, if given arguments other than something numeric, then the
|
28
|
+
argument will be coerced to a float. If it cannot be coerced to a float,
|
29
|
+
it will raise an exception.
|
30
|
+
|
31
|
+
For the conversions, there are some expectations:
|
32
|
+
|
33
|
+
* For latitude, you must provide an argument within the bounds of `-90` and `90`.
|
34
|
+
* For longitude, you must provide an argument within the bounds of `-180` and `180`.
|
35
|
+
|
36
|
+
You can see more information in the objects and errors themselves.
|
37
|
+
|
27
38
|
Usage is simple:
|
28
39
|
|
29
40
|
### Convert from Degrees, Minutes, Seconds, and Direction to a float
|
30
41
|
|
31
42
|
```ruby
|
32
|
-
# This can be any positive number between 0 and 360. It will be coerced
|
33
|
-
# to a float and absoluted.
|
43
|
+
# This can be any positive number between 0 and 360. It will be coerced to a float and absoluted.
|
34
44
|
degrees = 12
|
35
45
|
|
36
46
|
# Minutes
|
@@ -42,8 +52,7 @@ seconds = 42.42
|
|
42
52
|
# Direction must be one of N, S, E, or W
|
43
53
|
direction = 'w'
|
44
54
|
|
45
|
-
conversion = GeoPosition::Conversion::Dms.new(degrees, minutes, seconds,
|
46
|
-
direction)
|
55
|
+
conversion = GeoPosition::Conversion::Dms.new(degrees, minutes, seconds, direction)
|
47
56
|
|
48
57
|
conversion.to_s
|
49
58
|
=> "12 deg 3' 42.42\" W"
|
@@ -94,8 +103,6 @@ parser.to_hash
|
|
94
103
|
=> {:degrees=>77, :minutes=>8, :seconds=>42.0, :direction=>"W"}
|
95
104
|
```
|
96
105
|
|
97
|
-
|
98
|
-
|
99
106
|
## Todo
|
100
107
|
|
101
108
|
* Add a command line component
|
@@ -30,9 +30,9 @@ module GeoPosition
|
|
30
30
|
def initialize(degrees, minutes, seconds, direction)
|
31
31
|
raise GeoPosition::Error::InvalidDirectionError.new("Please provided a direction of N, S, E, or W") unless valid_direction?(direction)
|
32
32
|
raise GeoPosition::Error::InvalidFloatError.new("Arguments could not be coerced to a float") unless valid_floats?([degrees, minutes, seconds])
|
33
|
-
raise GeoPosition::Error::InvalidDegreesError.new("Degrees must be between 0 and
|
33
|
+
raise GeoPosition::Error::InvalidDegreesError.new("Degrees must be between 0 and 180. %s was provided" % [degrees]) unless valid_degrees?(degrees)
|
34
34
|
raise GeoPosition::Error::InvalidMinutesError.new("Minutes must be between 0 and 60. %s was provided" % [minutes]) unless valid_minutes?(minutes)
|
35
|
-
raise GeoPosition::Error::InvalidSecondsError.new("
|
35
|
+
raise GeoPosition::Error::InvalidSecondsError.new("Seconds must be between 0 and 60. %s was provided" % [seconds]) unless valid_seconds?(seconds)
|
36
36
|
|
37
37
|
@degrees = degrees
|
38
38
|
@minutes = minutes
|
data/lib/geo_position/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_position
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash:
|
130
|
+
hash: -1422890364485942241
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
segments:
|
138
138
|
- 0
|
139
|
-
hash:
|
139
|
+
hash: -1422890364485942241
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
142
|
rubygems_version: 1.8.24
|