array_op_custom 0.1.4 → 0.1.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/array_op_custom.rb +24 -6
- data/lib/array_op_custom/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b3d18e41cbc2c5e0b9c17ad6679dbccb02f0dde60d527c85c66c5dd7bbc31b8
|
4
|
+
data.tar.gz: 5282bf198ea394ba42922bbab1ff25b08749242e57ec83f9dfe4299edf334504
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60ce0026ca4c45e25bec409ae6cee86cc1d593b88108addff4770fd27f69e7d3a4f6249381accc5d5c6ee1ab554deef80c9326cb8f2bf2d64c4f1b0df30d3c39
|
7
|
+
data.tar.gz: 5e9699370a190d3d57a7bfc4a3cd9d1dde4193a0dbe03e093ccbbc04def50750fa5f891312a6e6ae412002e5140eeb4c3664bb52ff0565001744bb3752b2ffcb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -32,7 +32,7 @@ require 'array_op_custom'
|
|
32
32
|
#=> [5, 7, 9, 4]
|
33
33
|
|
34
34
|
[1, 2, 3] + [4, 5, 6, 7]
|
35
|
-
#=> [5, 7, 9]
|
35
|
+
#=> [5, 7, 9, 7]
|
36
36
|
|
37
37
|
[1, 2, 3] * [4, 5, 6]
|
38
38
|
#=> [4, 10, 18]
|
@@ -41,7 +41,7 @@ require 'array_op_custom'
|
|
41
41
|
#=> [4, 10, 18, 4]
|
42
42
|
|
43
43
|
[1, 2, 3] * [4, 5, 6, 7]
|
44
|
-
#=> [4, 10, 18]
|
44
|
+
#=> [4, 10, 18, 7]
|
45
45
|
|
46
46
|
[1, 2, 3] - [4, 5, 6]
|
47
47
|
#=> [3, 3, 3]
|
data/lib/array_op_custom.rb
CHANGED
@@ -7,18 +7,36 @@ module ArrayOpCustom
|
|
7
7
|
end
|
8
8
|
class Array
|
9
9
|
def +(other)
|
10
|
-
self.
|
11
|
-
self
|
10
|
+
if self.length >= other.length
|
11
|
+
self.each_index do |i|
|
12
|
+
self[i] = other[i] ? self[i] + other[i] : self[i]
|
13
|
+
end
|
14
|
+
elsif other.length > self.length
|
15
|
+
other.each_index do |i|
|
16
|
+
other[i] = self[i] ? self[i] + other[i] : other[i]
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
def *(other)
|
15
|
-
self.
|
16
|
-
self
|
21
|
+
if self.length >= other.length
|
22
|
+
self.each_index do |i|
|
23
|
+
self[i] = other[i] ? self[i] * other[i] : self[i]
|
24
|
+
end
|
25
|
+
elsif other.length > self.length
|
26
|
+
other.each_index do |i|
|
27
|
+
other[i] = self[i] ? self[i] * other[i] : other[i]
|
28
|
+
end
|
17
29
|
end
|
18
30
|
end
|
19
31
|
def -(other)
|
20
|
-
self.
|
21
|
-
self
|
32
|
+
if self.length >= other.length
|
33
|
+
self.each_index do |i|
|
34
|
+
self[i] = other[i] ? (self[i] - other[i]).abs : self[i]
|
35
|
+
end
|
36
|
+
elsif other.length > self.length
|
37
|
+
other.each_index do |i|
|
38
|
+
other[i] = self[i] ? (self[i] - other[i]).abs : other[i]
|
39
|
+
end
|
22
40
|
end
|
23
41
|
end
|
24
42
|
def to_i
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: array_op_custom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k-kyg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|