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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9832901428c79dcc273234e400297439cab76c23d2073dd6771015d0c366817
4
- data.tar.gz: 3c3ec600a924b0274eb3101492cd7e3a6a0f2be0e0b574bdc21e21b70873dd07
3
+ metadata.gz: 9b3d18e41cbc2c5e0b9c17ad6679dbccb02f0dde60d527c85c66c5dd7bbc31b8
4
+ data.tar.gz: 5282bf198ea394ba42922bbab1ff25b08749242e57ec83f9dfe4299edf334504
5
5
  SHA512:
6
- metadata.gz: cf4b3980f846cc0a65032053daa9a3dfd2b61c0674f5dd4c5c4b9941c8cc59c123369e19a00d6794e1879584db7afd77f5f61d02b2edcef68ffa551557502e53
7
- data.tar.gz: be029eec0a0e945c5e3838638262511df2decd1ccd6b8839cf01cb2c7802b0b516dce9131a4a8a0be585a42c26682f821bc03114ffd89cc6b9b1bd3e6b557740
6
+ metadata.gz: 60ce0026ca4c45e25bec409ae6cee86cc1d593b88108addff4770fd27f69e7d3a4f6249381accc5d5c6ee1ab554deef80c9326cb8f2bf2d64c4f1b0df30d3c39
7
+ data.tar.gz: 5e9699370a190d3d57a7bfc4a3cd9d1dde4193a0dbe03e093ccbbc04def50750fa5f891312a6e6ae412002e5140eeb4c3664bb52ff0565001744bb3752b2ffcb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- array_op_custom (0.1.4)
4
+ array_op_custom (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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]
@@ -7,18 +7,36 @@ module ArrayOpCustom
7
7
  end
8
8
  class Array
9
9
  def +(other)
10
- self.each_index do |i|
11
- self[i] = other[i] ? self[i] + other[i] : self[i]
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.each_index do |i|
16
- self[i] = other[i] ? self[i] * other[i] : self[i]
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.each_index do |i|
21
- self[i] = other[i] ? (self[i] - other[i]).abs : self[i]
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
@@ -1,3 +1,3 @@
1
1
  module ArrayOpCustom
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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
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-15 00:00:00.000000000 Z
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler