chingu_vectors 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +2 -0
  2. data/lib/actual_vectors.rb +2 -2
  3. data/lib/vector.rb +17 -1
  4. metadata +2 -2
data/README CHANGED
@@ -40,6 +40,8 @@ This would be a method that lets a ball follow another ball ("follow") nice and
40
40
  end
41
41
 
42
42
  == Changelog
43
+ [1.1.1] * Applies on default
44
+ * Fixed eql? and hash for Vector
43
45
  [1.1.0] * Fixed a problem where vectors would prevent other traits from executing update_trait
44
46
  [1.0.2] * Fixed problem with gemspec
45
47
  * Fixed Example a
@@ -4,7 +4,8 @@ module Chingu
4
4
 
5
5
  DEFAULT_OPTIONS = { :position => [0, 0],
6
6
  :speed => [0, 0],
7
- :hastening => [0, 0] }
7
+ :hastening => [0, 0],
8
+ :apply => true }
8
9
 
9
10
  module ClassMethods
10
11
  #
@@ -35,7 +36,6 @@ module Chingu
35
36
  # (with defaults [0,0] respectively) <br>
36
37
  #
37
38
  def setup_trait options
38
- puts "setup trait in vectors called"
39
39
  trait_options[:vectors] = DEFAULT_OPTIONS.merge(options)
40
40
  self.position = trait_options[:vectors][:position]
41
41
  self.speed = trait_options[:vectors][:speed]
@@ -13,7 +13,23 @@ module Chingu
13
13
  include Comparable
14
14
 
15
15
  def <=>(other)
16
- length <=> other.length
16
+ x_comp = self.x <=> other.x
17
+ if x_comp == 0
18
+ self.y <=> other.y
19
+ else
20
+ x_comp
21
+ end
22
+ end
23
+
24
+ def eql?(other)
25
+ self.x == other.x &&
26
+ self.y == other.y
27
+ end
28
+
29
+ alias == eql?
30
+
31
+ def hash
32
+ x.hash ^ y.hash
17
33
  end
18
34
 
19
35
  include Enumerable
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chingu_vectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
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: 2012-07-13 00:00:00.000000000 Z
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chingu