fe_core_ext 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fe_core_ext/core_ext/array.rb +27 -0
- data/lib/fe_core_ext/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19d199f9b1e53d03ea27d4344623d2fef4a1a51f
|
4
|
+
data.tar.gz: dee7a8d26ee853586c6068756d902fc3cd725ae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 675d1ccf81930636f29bc9f63c63b877f4ef49e9c2f9017932c06f9db97abeed537adcca65519e6ceca9e4b34a467f5b21a2d0b33a5f884d527bcffdb5f158f4
|
7
|
+
data.tar.gz: 0bdace3a4dcf40d91078c431fd14e9e9ab886b474fee498b4b8d863579d0c7e31ee4720f55cd28ec8730a784e424b66917bccb2d25bc34f6a3dcd0166caa7336
|
@@ -16,6 +16,33 @@ module FeCoreExt::CoreExt::Array
|
|
16
16
|
return if empty?
|
17
17
|
sum.to_d / size
|
18
18
|
end
|
19
|
+
|
20
|
+
# remove, remove_at, remove_if はこちらのものを使わせてもらっています。
|
21
|
+
# https://gist.github.com/nekoTheShadow/2de8a324f445bdde8a67
|
22
|
+
def remove(val)
|
23
|
+
# ブロックが渡されており、かつvalと等しい要素が見つからなかった場合
|
24
|
+
return yield if block_given? && !self.include?(val)
|
25
|
+
|
26
|
+
temp = self.dup
|
27
|
+
temp.delete(val)
|
28
|
+
temp
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_at(pos)
|
32
|
+
temp = self.dup
|
33
|
+
temp.delete_at(pos)
|
34
|
+
temp
|
35
|
+
end
|
36
|
+
|
37
|
+
def remove_if
|
38
|
+
temp = self.dup
|
39
|
+
# ブロックを持たない場合
|
40
|
+
return temp.delete_if unless block_given?
|
41
|
+
|
42
|
+
self.each{|val| temp.delete(val) if yield(val)}
|
43
|
+
temp
|
44
|
+
end
|
45
|
+
|
19
46
|
end
|
20
47
|
|
21
48
|
class Array
|
data/lib/fe_core_ext/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fe_core_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tetsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|