vector2d 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/vector2d.rb +3 -2
- data/lib/vector2d/version.rb +1 -1
- data/spec/lib/vector2d_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dbfd81a3fed2f7614e10055078fdbdd37755693
|
4
|
+
data.tar.gz: e3e0f41142cba937a0eba3a16b94a33ebd8d3a7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 526d578d2c1ca5b1c47c7e5552b0fd7493188ac58bf80a21768d5c2e0ce42baab3bbbd22e256c16561f30546c8cdf3aa46426857713da6494c27809171e3cedb
|
7
|
+
data.tar.gz: 5a139955b82cee23628966909c1dd8d12e46e7e8bafc539c48c9339e57fddc43bdf1712345f1576b5998a103a44df4fc1b220ace19b1b96cf8498b18ff776a87
|
data/Gemfile.lock
CHANGED
data/lib/vector2d.rb
CHANGED
@@ -78,9 +78,10 @@ class Vector2d
|
|
78
78
|
Contract String => Vector2d
|
79
79
|
def parse_str(str)
|
80
80
|
if str =~ /^[\s]*[\d\.]*[\s]*x[\s]*[\d\.]*[\s]*$/
|
81
|
-
|
81
|
+
x, y = str.split("x")
|
82
|
+
new(x.to_f, y.to_f)
|
82
83
|
else
|
83
|
-
|
84
|
+
fail ArgumentError, "not a valid string input"
|
84
85
|
end
|
85
86
|
end
|
86
87
|
end
|
data/lib/vector2d/version.rb
CHANGED
data/spec/lib/vector2d_spec.rb
CHANGED
@@ -34,6 +34,16 @@ describe Vector2d do
|
|
34
34
|
it_behaves_like "a parsed vector", [1.0, 2.0]
|
35
35
|
end
|
36
36
|
|
37
|
+
context "with string argument, first omitted" do
|
38
|
+
subject(:vector) { Vector2d.parse("x200") }
|
39
|
+
it_behaves_like "a parsed vector", [0, 200]
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with string argument, second omitted" do
|
43
|
+
subject(:vector) { Vector2d.parse("200x") }
|
44
|
+
it_behaves_like "a parsed vector", [200, 0]
|
45
|
+
end
|
46
|
+
|
37
47
|
context "with string argument, fixnum" do
|
38
48
|
subject(:vector) { Vector2d.parse("1x2") }
|
39
49
|
it_behaves_like "a parsed vector", [1, 2]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vector2d
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|