clazz_extensions 0.0.4 → 0.0.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/lib/clazz_extensions/array.rb +20 -16
- data/lib/clazz_extensions/string.rb +5 -1
- data/lib/clazz_extensions/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed6f197828b33851bf960cf9e5d5fc1ba6b583ef
|
4
|
+
data.tar.gz: c16d5bc64214c25a9bc96c2a16b6dca45fc5ddf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6707ceb1c2505b6900e0781c114911918e55916da2e7a58edf98c4063971197bca3749c401fac2e00157e3a6167306e46d360f33cdcfae402bb85c40331da2db
|
7
|
+
data.tar.gz: d13af233f162fb3371bfd807db99dacfc7d9ab0aa8325d46692cc6c16de12abd2a58942e26bc06de021f5ed9f2226149f8068c0faac7e6753784e294436d4869
|
@@ -1,22 +1,26 @@
|
|
1
1
|
module ClazzExtensions
|
2
2
|
class Array < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def duplication( clazz, _ )
|
4
|
+
clazz.select { |v|
|
5
|
+
clazz.count( v ) > 1
|
6
|
+
}.uniq!
|
7
|
+
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
end
|
9
|
+
def blank?( clazz, _ )
|
10
|
+
clazz.size == 0
|
11
|
+
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
def duplication!( clazz, _ )
|
14
|
+
duplicate( clazz, args ).each { |v|
|
15
|
+
clazz.delete( v )
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def unduplication( clazz, _ )
|
20
|
+
unduplicate_value = clazz.select { |v|
|
21
|
+
clazz.count( v ) <= 1
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
@@ -4,10 +4,14 @@ module ClazzExtensions
|
|
4
4
|
to_class_name( clazz )
|
5
5
|
end
|
6
6
|
|
7
|
+
def blank?( clazz, _ )
|
8
|
+
clazz.size == 0
|
9
|
+
end
|
10
|
+
|
7
11
|
def to_const( clazz, _ )
|
8
12
|
clazz_name = to_class_name( clazz )
|
9
13
|
|
10
|
-
if Class.const_defined?( clazz_name )
|
14
|
+
if !blank?(clazz_name, []) and Class.const_defined?( clazz_name )
|
11
15
|
Class.const_get( clazz_name )
|
12
16
|
else
|
13
17
|
nil
|