rudash 2.6.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rudash/union.rb +25 -0
  3. data/lib/rudash.rb +2 -0
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60a8c07b41dbc424ce6a7c68759c0320ba21f0e7ed6836be5148c74a9d0fafc8
4
- data.tar.gz: 80f3cb474075ef7495806343ee97e20eaaa5bbf031d06f00bfc69e40d2bfc069
3
+ metadata.gz: 1be883b432dd317e12aa88cf12390e067292d866cb30ce89f0fd43826f75de74
4
+ data.tar.gz: fca7e87890b36e9e1423f5f5d1661d23db04834d08cb5b247f72e26dd9747ee4
5
5
  SHA512:
6
- metadata.gz: 1a7a49beea7967a040a985393dc1064287b1eb814df582343c4f25abe55cc7a1e7857d3666137e131c1c92f660ab6f56bcc01b3d53a84fc04fa5152dc8c189f1
7
- data.tar.gz: 6548affd038871d4ff3daea1a3c8df1b77c53aba02ac4c3773ab98d31b09374d11987cb0a572c8e553435a0e24f0be30b1a64bdd2172351bca98b48069bb3421
6
+ metadata.gz: 80dd01987d0301f1f5311d1b3e2278d71d2662d0eacd2864abb196224621fd878c276e11edc10288f7269340658685f760f8c5a1bd0e123fc3b283a56c998402
7
+ data.tar.gz: 2c4e8f9a515c7877518d30376a9a4b5692c3a517cd2be2f45bf0c1dff483526a3ab8cab46aa9b57b8564cc129edb48352a0db925b05aeeacd793ba1e23481236
@@ -0,0 +1,25 @@
1
+ require_relative 'reduce.rb'
2
+ require_relative 'head.rb'
3
+ require_relative 'filter.rb'
4
+
5
+ module Union
6
+ extend Reduce
7
+ extend Head
8
+ extend Filter
9
+
10
+ def union(*values)
11
+
12
+ union_reducer = -> (acc, current) {
13
+ return acc if !current.is_a?(Array) || !acc.is_a?(Array)
14
+ acc | current
15
+ }
16
+
17
+ is_array = -> (value) { value.is_a?(Array) }
18
+
19
+ arr_values = self.filter(values, is_array)
20
+ head = self.head(arr_values)
21
+ return [] if !head.is_a?(Array)
22
+
23
+ self.reduce(arr_values, union_reducer, head)
24
+ end
25
+ end
data/lib/rudash.rb CHANGED
@@ -43,6 +43,7 @@ require_relative './rudash/pick.rb'
43
43
  require_relative './rudash/update.rb'
44
44
  require_relative './rudash/slice.rb'
45
45
  require_relative './rudash/remove.rb'
46
+ require_relative './rudash/union.rb'
46
47
 
47
48
  class R_
48
49
  extend Map
@@ -90,4 +91,5 @@ class R_
90
91
  extend Update
91
92
  extend Slice
92
93
  extend Remove
94
+ extend Union
93
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rudash
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Islam Attrash
@@ -59,6 +59,7 @@ files:
59
59
  - lib/rudash/slice.rb
60
60
  - lib/rudash/some.rb
61
61
  - lib/rudash/tail.rb
62
+ - lib/rudash/union.rb
62
63
  - lib/rudash/uniq.rb
63
64
  - lib/rudash/update.rb
64
65
  - lib/rudash/without.rb