coords 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/Rakefile +9 -1
- data/coords.gemspec +7 -1
- data/lib/coords/cartesian2d.rb +4 -0
- data/lib/coords/version.rb +1 -1
- data/lib/coords.rb +2 -0
- data/spec/lib/coords/cartesian2d_spec.rb +53 -0
- data/spec/spec_helper.rb +2 -0
- metadata +48 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2849b8793d903cd5b5435ef01744b5bd792603ad
|
4
|
+
data.tar.gz: a32e790ce5e5fbba6b683ab3c7127ff8d3ed6b88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c51450ad8eed5bd725cb33f0c487ee4570d06b8febf616c45bd64f01bb8c0f535f7d195094db5961b1e9f467776e967e80f0bb48e0691793f2264b17d24bce5e
|
7
|
+
data.tar.gz: e5018d57fba2c6ed8127998022b6729d2d5011823c1d65f4fd8431315b42513cb9b9528acffd3516f5229d752c4ab2d9ae1fa9752a5871cbb0e1360577fe2d87
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Coords
|
2
2
|
|
3
|
-
|
3
|
+
A small suite of coordinate system classes allowing distance calculations and conversions between types.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -17,12 +17,14 @@ Or install it yourself as:
|
|
17
17
|
$ gem install coords
|
18
18
|
|
19
19
|
## Usage
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
```ruby
|
21
|
+
point = Coords::Cartesian2d.new(1, 2)
|
22
|
+
d = point.distance(point2)
|
23
|
+
polar_point = point.to_polar
|
24
|
+
```
|
23
25
|
## Contributing
|
24
26
|
|
25
|
-
1. Fork it ( https://github.com/
|
27
|
+
1. Fork it ( https://github.com/ceud/coords/fork )
|
26
28
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
29
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
30
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,2 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'bundler/gem_tasks'
|
2
3
|
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
# task.rspec_opts = ['--color', '--format', 'nested']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
data/coords.gemspec
CHANGED
@@ -20,5 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
# spec.add_development_dependency "rspec-nc"
|
25
|
+
# spec.add_development_dependency "guard"
|
26
|
+
# spec.add_development_dependency "guard-rspec"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "pry-remote"
|
29
|
+
spec.add_development_dependency "pry-nav"
|
24
30
|
end
|
data/lib/coords/cartesian2d.rb
CHANGED
data/lib/coords/version.rb
CHANGED
data/lib/coords.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coords::Cartesian2d do
|
4
|
+
subject { Coords::Cartesian2d.new(1, 2) }
|
5
|
+
|
6
|
+
describe '#x' do
|
7
|
+
it 'returns value of x coordinate' do
|
8
|
+
expect(subject.x).to eq(1)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#y' do
|
13
|
+
it 'returns value of y coordinate' do
|
14
|
+
expect(subject.y).to eq(2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#distance_squared' do
|
19
|
+
it 'returns squared distance between two points' do
|
20
|
+
point2 = Coords::Cartesian2d.new(4, 6)
|
21
|
+
expect(subject.distance_squared(point2)).to eq(25)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#distance' do
|
26
|
+
it 'returns distance between two points' do
|
27
|
+
point2 = Coords::Cartesian2d.new(4, 6)
|
28
|
+
expect(subject.distance(point2)).to eq(5)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#to_s' do
|
33
|
+
it 'returns comma delimited coordinate values' do
|
34
|
+
expect(subject.to_s).to eq('1,2')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#to_polar' do
|
39
|
+
it 'returns point in polar coordinate system' do
|
40
|
+
polar = subject.to_polar
|
41
|
+
expect(polar.radius).to eq(2.23606797749979)
|
42
|
+
expect(polar.theta).to eq(1.1071487177940904)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#==' do
|
47
|
+
it 'compares coordinate values equality' do
|
48
|
+
point2 = Coords::Cartesian2d.new(1, 2)
|
49
|
+
expect(subject == point2).to be true
|
50
|
+
expect(subject != point2).to be false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Allan
|
@@ -52,6 +52,48 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-remote
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-nav
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
description: Coordinate system library enabling cross-system conversions.
|
56
98
|
email:
|
57
99
|
- ceudonym@gmail.com
|
@@ -71,6 +113,8 @@ files:
|
|
71
113
|
- lib/coords/polar.rb
|
72
114
|
- lib/coords/spherical.rb
|
73
115
|
- lib/coords/version.rb
|
116
|
+
- spec/lib/coords/cartesian2d_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
74
118
|
homepage: https://github.com/ceud/coords
|
75
119
|
licenses:
|
76
120
|
- MIT
|
@@ -95,5 +139,7 @@ rubygems_version: 2.4.6
|
|
95
139
|
signing_key:
|
96
140
|
specification_version: 4
|
97
141
|
summary: A small suite of coordinate system classes.
|
98
|
-
test_files:
|
142
|
+
test_files:
|
143
|
+
- spec/lib/coords/cartesian2d_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
99
145
|
has_rdoc:
|