set_theory 0.0.3 → 0.0.4

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 CHANGED
@@ -20,6 +20,7 @@ _Or choose the parts you want_
20
20
  require 'set_theory/union'
21
21
  require 'set_theory/intersection'
22
22
  require 'set_theory/difference'
23
+ require 'set_theory/symmetric_difference'
23
24
 
24
25
  Usage
25
26
  -----
@@ -0,0 +1,5 @@
1
+ class Array
2
+ def symmetric_difference(ary)
3
+ (self | ary) - (self & ary)
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  class Array
2
2
  def union(ary)
3
- (self + ary).uniq
3
+ self | ary
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module SetTheory
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/set_theory.rb CHANGED
@@ -2,3 +2,4 @@ require "set_theory/member_of"
2
2
  require "set_theory/union"
3
3
  require "set_theory/intersection"
4
4
  require "set_theory/difference"
5
+ require "set_theory/symmetric_difference"
@@ -0,0 +1,13 @@
1
+ require 'set_theory/symmetric_difference'
2
+
3
+ describe Array do
4
+ it 'responds to #symmetric_difference' do
5
+ Array.new.respond_to?(:symmetric_difference).should be
6
+ end
7
+
8
+ describe '#symmetric_difference' do
9
+ it 'performs the symmetric_difference of two sets' do
10
+ ([1, 2, 3].symmetric_difference [2, 3, 4]).should eql [1, 4]
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: set_theory
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Preston
@@ -90,12 +90,14 @@ files:
90
90
  - lib/set_theory/difference.rb
91
91
  - lib/set_theory/intersection.rb
92
92
  - lib/set_theory/member_of.rb
93
+ - lib/set_theory/symmetric_difference.rb
93
94
  - lib/set_theory/union.rb
94
95
  - lib/set_theory/version.rb
95
96
  - set_theory.gemspec
96
97
  - spec/set_theory/difference_spec.rb
97
98
  - spec/set_theory/intersection_spec.rb
98
99
  - spec/set_theory/member_of_spec.rb
100
+ - spec/set_theory/symmetric_difference_spec.rb
99
101
  - spec/set_theory/union_spec.rb
100
102
  has_rdoc: true
101
103
  homepage: http://github.com/tehpeh/set_theory
@@ -129,4 +131,5 @@ test_files:
129
131
  - spec/set_theory/difference_spec.rb
130
132
  - spec/set_theory/intersection_spec.rb
131
133
  - spec/set_theory/member_of_spec.rb
134
+ - spec/set_theory/symmetric_difference_spec.rb
132
135
  - spec/set_theory/union_spec.rb