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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffbc936cb0b24ca1c6971392b36e29b9d964cece86ab3fbfa81b8679cf51210d
4
- data.tar.gz: 3b6068b56d74e329a161d9baaf47fce237152fcd117cf0f61c0c03b1582faef5
3
+ metadata.gz: ed198bbbfd3e8c93142048362c85abd75951d7a0a0faf95921cff8d28338078d
4
+ data.tar.gz: 9bbeeadac664dffd079b1f1c1e259508807aebe694c09feb5e69890f45d6fe43
5
5
  SHA512:
6
- metadata.gz: 900bb0fa75ef4819b5c86e6657f24c9d425c81288361a0f5291d3af7947ab348021337a5666c6144274e91dd7b220d0c272315be7fd0d5905e39f62893ae2968
7
- data.tar.gz: 86d7e45d7fcd32a02bca5b225c56f9ec105465f0bdb28c51aef4035c251383460073a640c185851d30beeb6130a2397b04647bb79653be592fda545762341825
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
@@ -0,0 +1,2 @@
1
+ require_relative 'powertool/maybe_chain'
2
+ require_relative 'powertool/range'
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.3
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/range.rb
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 series of small improvements to Ruby classes
44
+ summary: A set of small improvements to Ruby classes
43
45
  test_files: []