vector2d 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1406edfe102d42ed1f904b284c2d60a3fb7ab377
4
- data.tar.gz: ad834281b90b577cb6b9d5e392cd27d8aed630cf
3
+ metadata.gz: e66f7c5a4f7dc7d945041bc94089919d161dd81f
4
+ data.tar.gz: 72e52f85daded8b240945fa886fb2c996baa6f3f
5
5
  SHA512:
6
- metadata.gz: f5894c2e97725decc4e019eef6fa43b597ab4e5349e09fd036d516763d687eac3d9d9c882cfc785ff6cfcf1f9f5cf1d50a73eb4f7afb3e84f24619cdd23f79bd
7
- data.tar.gz: 82bb98f6236e474dffc947c5ea8a95c52bb94d92c0e885cf95886129242b7e13fa4947042571ee3bc362b0414570c7ba95c8268971e3fdf21c8caa7d1e9172d0
6
+ metadata.gz: 16e3e2e590a4542559859ed212df578c4ccd73d2b1e4117b9ad9a70e20b793c10b5f320d5447e03df8d661dd1bcfb7967f9e69d281ba7a96c3a97efe93ed2281
7
+ data.tar.gz: 7d6aa7f2dfdf2644131fd50f860e978bf4ce6afa5381c6193859bfdfcf9d1d0882641ee2fee3328bf7a3de271763670e2cdc0577274310d2f46dea55e23a8ba4
data/.travis.yml CHANGED
@@ -1,3 +1,6 @@
1
+ addons:
2
+ code_climate:
3
+ repo_token: bf65d5faaf8dc80d0d58f2e7c663323734237c0a3e91cba16b1c556a98b0971e
1
4
  language: ruby
2
5
  rvm:
3
6
  - 1.9.3
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ group :test do
6
+ gem "codeclimate-test-reporter", require: false
7
+ end
data/Gemfile.lock CHANGED
@@ -1,12 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vector2d (2.0.0)
4
+ vector2d (2.0.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
+ codeclimate-test-reporter (0.3.0)
10
+ simplecov (>= 0.7.1, < 1.0.0)
9
11
  diff-lcs (1.2.5)
12
+ docile (1.1.4)
13
+ multi_json (1.10.1)
10
14
  rake (10.3.2)
11
15
  rspec (2.14.1)
12
16
  rspec-core (~> 2.14.0)
@@ -16,11 +20,17 @@ GEM
16
20
  rspec-expectations (2.14.5)
17
21
  diff-lcs (>= 1.1.3, < 2.0)
18
22
  rspec-mocks (2.14.6)
23
+ simplecov (0.8.2)
24
+ docile (~> 1.1.0)
25
+ multi_json
26
+ simplecov-html (~> 0.8.0)
27
+ simplecov-html (0.8.0)
19
28
 
20
29
  PLATFORMS
21
30
  ruby
22
31
 
23
32
  DEPENDENCIES
33
+ codeclimate-test-reporter
24
34
  rake (~> 10.3)
25
35
  rspec (~> 2.1)
26
36
  vector2d!
data/README.md CHANGED
@@ -1,24 +1,26 @@
1
- # Vector2d [![Build Status](https://travis-ci.org/elektronaut/vector2d.png)](https://travis-ci.org/elektronaut/vector2d) [![Code Climate](https://codeclimate.com/github/elektronaut/vector2d.png)](https://codeclimate.com/github/elektronaut/vector2d)
1
+ # Vector2d [![Build Status](https://travis-ci.org/elektronaut/vector2d.png)](https://travis-ci.org/elektronaut/vector2d) [![Code Climate](https://codeclimate.com/github/elektronaut/vector2d.png)](https://codeclimate.com/github/elektronaut/vector2d) [![Code Climate](https://codeclimate.com/github/elektronaut/vector2d/coverage.png)](https://codeclimate.com/github/elektronaut/vector2d)
2
2
 
3
3
  Vector2d handles two-dimensional coordinates and vectors.
4
4
  Vectors are immutable, meaning this is a purely functional library.
5
5
 
6
6
  ## Quick example
7
7
 
8
- require 'vector2d'
8
+ ```ruby
9
+ require 'vector2d'
9
10
 
10
- vector = Vector2d(50, 70)
11
+ vector = Vector2d(50, 70)
11
12
 
12
- vector.aspect_ratio # => 0.714285714285714
13
- vector.length # => 86.0232526704263
13
+ vector.aspect_ratio # => 0.714285714285714
14
+ vector.length # => 86.0232526704263
14
15
 
15
- vector * 2 # => Vector2d(140,100)
16
- vector + Vector2d(20, 30) # => Vector2d(100,70)
16
+ vector * 2 # => Vector2d(100,140)
17
+ vector + Vector2d(20, 30) # => Vector2d(70,100)
17
18
 
18
- vector.fit(Vector(64, 64)) # => Vector2d(64,45)
19
+ vector.fit(Vector2d(64, 64)) # => Vector2d(64,45)
19
20
 
20
- Vector2d.parse([50, 70]) # => Vector2d(50,70)
21
- Vector2d.parse("50x70") # => Vector2d(50,70)
21
+ Vector2d.parse([50, 70]) # => Vector2d(50,70)
22
+ Vector2d.parse("50x70") # => Vector2d(50,70)
23
+ ```
22
24
 
23
25
  ## Documentation
24
26
 
@@ -26,4 +28,6 @@ Vectors are immutable, meaning this is a purely functional library.
26
28
 
27
29
  ## License
28
30
 
31
+ Copyright (c) 2006-2014 Inge Jørgensen
32
+
29
33
  Vector2d is released under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -4,7 +4,7 @@ class Vector2d
4
4
  module Properties
5
5
  # Angle of vector.
6
6
  #
7
- # Vector(2, 3).angle # => 0.9827..
7
+ # Vector2d(2, 3).angle # => 0.9827..
8
8
  #
9
9
  def angle
10
10
  Math.atan2(y, x)
@@ -12,7 +12,7 @@ class Vector2d
12
12
 
13
13
  # Aspect ratio of vector.
14
14
  #
15
- # Vector(2, 3).aspect_ratio # => 0.6667..
15
+ # Vector2d(2, 3).aspect_ratio # => 0.6667..
16
16
  #
17
17
  def aspect_ratio
18
18
  (x.to_f / y.to_f).abs
@@ -20,7 +20,7 @@ class Vector2d
20
20
 
21
21
  # Length of vector.
22
22
  #
23
- # Vector(2, 3).length # => 3.6055..
23
+ # Vector2d(2, 3).length # => 3.6055..
24
24
  #
25
25
  def length
26
26
  Math.sqrt(squared_length)
@@ -28,7 +28,7 @@ class Vector2d
28
28
 
29
29
  # Squared length of vector.
30
30
  #
31
- # Vector(2, 3).squared_length # => 13
31
+ # Vector2d(2, 3).squared_length # => 13
32
32
  #
33
33
  def squared_length
34
34
  x * x + y * y
@@ -36,8 +36,8 @@ class Vector2d
36
36
 
37
37
  # Is this a normalized vector?
38
38
  #
39
- # Vector(0, 1).normalized? # => true
40
- # Vector(2, 3).normalized? # => false
39
+ # Vector2d(0, 1).normalized? # => true
40
+ # Vector2d(2, 3).normalized? # => false
41
41
  #
42
42
  def normalized?
43
43
  self.length.to_f == 1.0
@@ -2,6 +2,22 @@
2
2
 
3
3
  class Vector2d
4
4
  module Transformations
5
+ # Rounds vector to up nearest integer.
6
+ #
7
+ # Vector2d(2.4, 3.6).ceil # => Vector2d(3,4)
8
+ #
9
+ def ceil
10
+ self.class.new(x.ceil, y.ceil)
11
+ end
12
+
13
+ # Rounds vector to up nearest integer.
14
+ #
15
+ # Vector2d(2.4, 3.6).floor # => Vector2d(2,3)
16
+ #
17
+ def floor
18
+ self.class.new(x.floor, y.floor)
19
+ end
20
+
5
21
  # Normalizes the vector.
6
22
  #
7
23
  # vector = Vector2d(2, 3)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class Vector2d
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
@@ -5,6 +5,20 @@ require 'spec_helper'
5
5
  describe Vector2d::Transformations do
6
6
  subject(:vector) { Vector2d.new(2, 3) }
7
7
 
8
+ describe "#ceil" do
9
+ subject(:vector) { Vector2d.new(2.3, 3.3) }
10
+ it "rounds the vector up" do
11
+ expect(vector.ceil).to eq(Vector2d.new(3, 4))
12
+ end
13
+ end
14
+
15
+ describe "#floor" do
16
+ subject(:vector) { Vector2d.new(2.7, 3.6) }
17
+ it "rounds the vector down" do
18
+ expect(vector.floor).to eq(Vector2d.new(2, 3))
19
+ end
20
+ end
21
+
8
22
  describe "#normalize" do
9
23
  it "normalizes the vector" do
10
24
  expect(vector.normalize.x).to be_within(0.0001).of(0.5547)
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'vector2d'
3
+ require "codeclimate-test-reporter"
4
+ CodeClimate::TestReporter.start
5
+
6
+ require "vector2d"
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.0.0
4
+ version: 2.0.1
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: 2014-05-30 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake