array_op_custom 0.1.0 → 0.1.1
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/README.md +3 -1
- data/array_op_custom.gemspec +1 -1
- data/lib/array_op_custom.rb +14 -8
- 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: bc7c3faafe3980d5c93286b570357a6b84fa2c11b5be808df8bd87d4f3743e8b
|
4
|
+
data.tar.gz: 82d40876da3efc14b40cf9d5b3802de083276a89fe976fe591a891eb878d6d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ab7f340313a5993b9c8911b037d8d2756a01f8eb1e317a0f58a7929945c911d8fb2784f5eae4147dcb6fafdcbf923d53ffa1398bed826d074a79ed7cbc0aff5
|
7
|
+
data.tar.gz: 00226f84499da84d828993d658ac9f0c67a4ce0bd723bd6d045766e914cea0791359b7a483c1b414622ff9dbf27acbf09ffa19f3fa3044dc5ae9be2f148ebda9
|
data/README.md
CHANGED
@@ -40,6 +40,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
40
|
|
41
41
|
## Sample
|
42
42
|
```ruby
|
43
|
+
require 'array_op_custom'
|
44
|
+
|
43
45
|
[1, 2, 3] + [4, 5, 6]
|
44
46
|
#=> [5, 7, 9]
|
45
47
|
|
@@ -72,4 +74,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
72
74
|
|
73
75
|
[1, 2, 3].to_h
|
74
76
|
#=> {:"0"=>1, :"1"=>2, :"2"=>3}
|
75
|
-
```
|
77
|
+
```
|
data/array_op_custom.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "array_op_custom"
|
7
7
|
spec.version = ArrayOpCustom::VERSION
|
8
8
|
spec.authors = ["k-kyg"]
|
9
|
-
spec.email = ["
|
9
|
+
spec.email = [""]
|
10
10
|
|
11
11
|
spec.summary = %Q(custom array's operator)
|
12
12
|
spec.description = <<DESC
|
data/lib/array_op_custom.rb
CHANGED
@@ -7,18 +7,24 @@ module ArrayOpCustom
|
|
7
7
|
end
|
8
8
|
class Array
|
9
9
|
def +(other)
|
10
|
-
|
11
|
-
self
|
10
|
+
if other.class === 'Array'
|
11
|
+
self.each_index do |i|
|
12
|
+
self[i] = other[i] ? self[i] + other[i] : self[i]
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
14
16
|
def *(other)
|
15
|
-
|
16
|
-
self
|
17
|
+
if other.class === 'Array'
|
18
|
+
self.each_index do |i|
|
19
|
+
self[i] = other[i] ? self[i] * other[i] : self[i]
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
def -(other)
|
20
|
-
|
21
|
-
self
|
24
|
+
if other.class === 'Array'
|
25
|
+
self.each_index do |i|
|
26
|
+
self[i] = other[i] ? (self[i] - other[i]).abs : self[i]
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|
24
30
|
def to_i
|
@@ -33,5 +39,5 @@ class Array
|
|
33
39
|
h[b.to_s.to_sym] = a
|
34
40
|
end
|
35
41
|
return h
|
36
|
-
|
37
|
-
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k-kyg
|
@@ -58,7 +58,7 @@ description: |
|
|
58
58
|
add method
|
59
59
|
to_s, to_i, to_h.
|
60
60
|
email:
|
61
|
-
-
|
61
|
+
- ''
|
62
62
|
executables: []
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|