flattenum 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/flattenum.rb +31 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d457195d5ef43717903a6806dd6d1f8fc1e57be
|
4
|
+
data.tar.gz: 9228f7e2e9856892d6ae2d830c7ee23050878e77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d599e4129cd4b1a44c060432080d15aebf5774e6ce0bc97639a05ba16a4fc875ad3659a5169840d28ed283033360d398f9839f5132149eeea30b782641275b80
|
7
|
+
data.tar.gz: 65e316acc6a7314dfcdaddf5165d1df195a8ef811d6714e9d82d806513b5b2b41de2f29e37ad9b997a0f05e6e76ed2b1f808cec081a3c5dc46e925e138556b87
|
data/lib/flattenum.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module Flattenum
|
3
|
+
|
4
|
+
|
5
|
+
def self.should_flatten?(thing)
|
6
|
+
thing.is_a? Array or thing.is_a? Enumerator
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def flattenum(thing)
|
11
|
+
return enum_for(__callee__, thing) unless block_given?
|
12
|
+
|
13
|
+
if ::Flattenum.should_flatten?(thing)
|
14
|
+
thing.each do |potential_object|
|
15
|
+
flattenum(potential_object).each do |object|
|
16
|
+
yield object
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
else
|
21
|
+
yield thing
|
22
|
+
end
|
23
|
+
end
|
24
|
+
module_function :flattenum
|
25
|
+
|
26
|
+
|
27
|
+
class << self
|
28
|
+
alias_method :this, :flattenum
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flattenum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Lauber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Generate a 'flattened' Enumerator of objects
|
14
|
+
email: constructible.truth@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/flattenum.rb
|
20
|
+
homepage:
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.2.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Generate a 'flattened' Enumerator of objects
|
43
|
+
test_files: []
|