quickeach 0.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/quickeach.rb +30 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f01869b328138918b6127fc9e5364e8739c9d9f2dd8c1859041c94aa8a49279b
4
+ data.tar.gz: 91cf394c2712ea058e127701051daa34e907300fa0becba6babcdd0da56eb58e
5
+ SHA512:
6
+ metadata.gz: d2c6515e40cb5a0f0158d121515d6e158468fad9c5c217fc7113e0318b62d775f8175397d2afff87b3044f42e715e7f2e602b06682a0148e24c238aa0dcb6f48
7
+ data.tar.gz: 597afc8b26c0599b6e51cf044362961cf989fe5da59520c26efe51855f90167c969e6771ef98326bed87bcb2416d152815e80a358f68edd5fce35272343aba50
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ class QuickEach
4
+ def initialize enumerable
5
+ @enumerable = enumerable
6
+ end
7
+
8
+ def method_missing method, *args, &block
9
+ @enumerable.collect do |element|
10
+ element.send method, *args, &block
11
+ end
12
+ end
13
+ end
14
+
15
+ class Array
16
+ # copy method
17
+ define_method(
18
+ "__each".to_sym,
19
+ [].method(:each)
20
+ )
21
+
22
+ def each &block
23
+ return QuickEach.new self unless block_given?
24
+ __each &block
25
+ end
26
+ end
27
+
28
+ # array = ["alice", "bob", "jon doe"]
29
+ # array.each.length
30
+ # => [5, 3, 6]
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quickeach
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Martin Wiegand
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: "[1,22,333].each.length -> [1,2,3]"
14
+ email: martin@wiegand.tel
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - quickeach.rb
20
+ homepage: https://github.com/CroneKorkN/ruby-quickeach
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.7.6
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: "'.each' without a block"
44
+ test_files: []