powertools 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/powertool/maybe_chain.rb +27 -0
- data/lib/{range.rb → powertool/range.rb} +0 -0
- data/lib/powertools.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed198bbbfd3e8c93142048362c85abd75951d7a0a0faf95921cff8d28338078d
|
4
|
+
data.tar.gz: 9bbeeadac664dffd079b1f1c1e259508807aebe694c09feb5e69890f45d6fe43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0091acf40578b33fbf35c7a38c8816d1e1fcf9543b298e8ab95ede575e4b443a17acee729ed0a40c1a917d58ec728cbcb315a4442d6488894d945a0a7233e71d'
|
7
|
+
data.tar.gz: d9d61c01d78960bcc6a096271a4b532d436db527b1610a6230c7846d0d1d1471577fb2c9f77555944d133476e66f4bdc5665ae4590562a985c197fff524c6542
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Hash
|
2
|
+
def maybe_chain(args = [])
|
3
|
+
return nil unless self
|
4
|
+
|
5
|
+
r = self
|
6
|
+
args.each_with_index do |a, _i|
|
7
|
+
return nil if r[a].nil? || (r.class != Hash && r.class != Array)
|
8
|
+
|
9
|
+
r = a.instance_of?(Range) ? a.map { |i| r[i] } : r[a]
|
10
|
+
end
|
11
|
+
r
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Array
|
16
|
+
def maybe_chain(args = [])
|
17
|
+
return nil unless self
|
18
|
+
|
19
|
+
r = self
|
20
|
+
args.each_with_index do |a, _i|
|
21
|
+
return nil if r[a].nil? || (r.class != Hash && r.class != Array)
|
22
|
+
|
23
|
+
r = a.instance_of?(Range) ? a.map { |i| r[i] } : r[a]
|
24
|
+
end
|
25
|
+
r
|
26
|
+
end
|
27
|
+
end
|
File without changes
|
data/lib/powertools.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: powertools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C. Kinniburgh
|
@@ -16,7 +16,9 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
-
- lib/
|
19
|
+
- lib/powertool/maybe_chain.rb
|
20
|
+
- lib/powertool/range.rb
|
21
|
+
- lib/powertools.rb
|
20
22
|
homepage: http://github.com/cjkinni/powertools
|
21
23
|
licenses:
|
22
24
|
- MIT
|
@@ -39,5 +41,5 @@ requirements: []
|
|
39
41
|
rubygems_version: 3.2.22
|
40
42
|
signing_key:
|
41
43
|
specification_version: 4
|
42
|
-
summary: A
|
44
|
+
summary: A set of small improvements to Ruby classes
|
43
45
|
test_files: []
|