mug 0.10.0 → 0.11.0

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: e8607d458014afe4661b3cd1f1cfc0fa87971047
4
- data.tar.gz: 4d154a7385f638a161b1c074a0f6075fa891da49
3
+ metadata.gz: 2538a79aa41d8fc9c2d9853158e0eaf462304ca9
4
+ data.tar.gz: 880a095ca3389180799b05451ffa3a88c86534b1
5
5
  SHA512:
6
- metadata.gz: 45dea11f88053bcfba35a38c1fecf8f3f9b28c5651a34d9112dc3ed1db46c0d4b28faae74bdf1c34924a7aa1315e539851b5390044b4cefe0818fc45edf4f153
7
- data.tar.gz: 9268e8c575aab051f3809de7bd55f1a454811e98771ac40fa1db549e57e141b8a9053788582e206482e4969e204f481d6e00430ecfa36bf29fa5bad17ed1bfd4
6
+ metadata.gz: 1d83d1d967f680d5ed16c9c9c638b08001a924ec57d6d674ad11f64a6dbc40b3babac8077a3a0b6dda60d9b087f20b789e8693a8780e7fb894fc8cf0033d82c4
7
+ data.tar.gz: 7b5731f832521b813e6fec5ad79e859f401faabebfac142b518e7bea8129e9a7154b7db6509bb5b9f23a1da1e19e252a9ec17e2fadd9169caf7ecd4f58f67b7d
@@ -34,10 +34,28 @@ class Array
34
34
  end
35
35
  end
36
36
 
37
+ ##
38
+ # Get the elements unique to one of two arrays.
39
+ #
40
+ # Duplicates in either array are included only once.
41
+ #
42
+ def ^ other
43
+ left = uniq
44
+ right = []
45
+ other.uniq.each do |x|
46
+ if left.include? x
47
+ left.delete x
48
+ elsif ! right.include?(x)
49
+ right << x
50
+ end
51
+ end
52
+ left + right
53
+ end
54
+
37
55
  end
38
56
 
39
57
  =begin
40
- Copyright (c) 2015, Matthew Kerwin <matthew@kerwin.net.au>
58
+ Copyright (c) 2017, Matthew Kerwin <matthew@kerwin.net.au>
41
59
 
42
60
  Permission to use, copy, modify, and/or distribute this software for any
43
61
  purpose with or without fee is hereby granted, provided that the above
@@ -15,5 +15,15 @@ class Test_array_minus < Test::Unit::TestCase
15
15
  assert_equal( [c,d], a.minus(b, remainder: true ) )
16
16
  assert_equal( [d,c], b.minus(a, remainder: true ) )
17
17
  end
18
+
19
+ def test_array_xor
20
+ [
21
+ [%w[a b c], %w[b c d], %w[a d]],
22
+ [%w[a c b c a], %w[b d c d b], %w[a d]],
23
+ ].each do |a, b, x|
24
+ assert_equal( x, a ^ b )
25
+ end
26
+ end
27
+
18
28
  end
19
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Kerwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  == MUG: Matty's Ultimate Gem