polyfill 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +3 -2
- data/CHANGELOG.md +26 -10
- data/CONTRIBUTING.md +0 -2
- data/README.md +107 -28
- data/lib/polyfill.rb +168 -74
- data/lib/polyfill/utils.rb +8 -3
- data/lib/polyfill/v2_2.rb +9 -0
- data/lib/polyfill/v2_2/enumerable.rb +34 -0
- data/lib/polyfill/v2_2/kernel.rb +9 -0
- data/lib/polyfill/v2_3.rb +2 -0
- data/lib/polyfill/v2_3/array.rb +22 -3
- data/lib/polyfill/v2_3/enumerable.rb +48 -3
- data/lib/polyfill/v2_3/enumerator/lazy.rb +7 -3
- data/lib/polyfill/v2_3/hash.rb +39 -3
- data/lib/polyfill/v2_3/kernel.rb +17 -0
- data/lib/polyfill/v2_3/string.rb +23 -5
- data/lib/polyfill/v2_3/struct.rb +22 -3
- data/lib/polyfill/v2_4/array.rb +25 -3
- data/lib/polyfill/v2_4/comparable.rb +9 -3
- data/lib/polyfill/v2_4/dir.rb +5 -3
- data/lib/polyfill/v2_4/enumerable.rb +28 -3
- data/lib/polyfill/v2_4/enumerator/lazy.rb +15 -3
- data/lib/polyfill/v2_4/file.rb +5 -3
- data/lib/polyfill/v2_4/float.rb +38 -3
- data/lib/polyfill/v2_4/hash.rb +35 -3
- data/lib/polyfill/v2_4/i_p_addr.rb +11 -3
- data/lib/polyfill/v2_4/integer.rb +53 -3
- data/lib/polyfill/v2_4/io.rb +166 -4
- data/lib/polyfill/v2_4/match_data.rb +11 -3
- data/lib/polyfill/v2_4/numeric.rb +15 -3
- data/lib/polyfill/v2_4/object.rb +9 -3
- data/lib/polyfill/v2_4/pathname.rb +7 -3
- data/lib/polyfill/v2_4/regexp.rb +3 -3
- data/lib/polyfill/v2_4/string.rb +110 -4
- data/lib/polyfill/v2_4/string_io.rb +166 -2
- data/lib/polyfill/v2_4/symbol.rb +17 -3
- data/lib/polyfill/version.rb +1 -1
- data/polyfill.gemspec +1 -1
- metadata +7 -98
- data/lib/polyfill/v2_3/array/instance.rb +0 -11
- data/lib/polyfill/v2_3/array/instance/dig.rb +0 -42
- data/lib/polyfill/v2_3/enumerable/instance.rb +0 -15
- data/lib/polyfill/v2_3/enumerable/instance/chunk_while.rb +0 -70
- data/lib/polyfill/v2_3/enumerable/instance/grep_v.rb +0 -48
- data/lib/polyfill/v2_3/enumerable/instance/slice_before.rb +0 -48
- data/lib/polyfill/v2_3/enumerator/lazy/instance.rb +0 -13
- data/lib/polyfill/v2_3/enumerator/lazy/instance/grep_v.rb +0 -31
- data/lib/polyfill/v2_3/hash/instance.rb +0 -15
- data/lib/polyfill/v2_3/hash/instance/dig.rb +0 -17
- data/lib/polyfill/v2_3/hash/instance/fetch_values.rb +0 -32
- data/lib/polyfill/v2_3/hash/instance/to_proc.rb +0 -23
- data/lib/polyfill/v2_3/string/class.rb +0 -11
- data/lib/polyfill/v2_3/string/class/new.rb +0 -33
- data/lib/polyfill/v2_3/string/instance.rb +0 -13
- data/lib/polyfill/v2_3/string/instance/minus_unary.rb +0 -23
- data/lib/polyfill/v2_3/string/instance/plus_unary.rb +0 -23
- data/lib/polyfill/v2_3/struct/instance.rb +0 -11
- data/lib/polyfill/v2_3/struct/instance/dig.rb +0 -17
- data/lib/polyfill/v2_4/array/instance.rb +0 -13
- data/lib/polyfill/v2_4/array/instance/concat.rb +0 -30
- data/lib/polyfill/v2_4/array/instance/sum.rb +0 -17
- data/lib/polyfill/v2_4/comparable/instance.rb +0 -11
- data/lib/polyfill/v2_4/comparable/instance/clamp.rb +0 -35
- data/lib/polyfill/v2_4/dir/class.rb +0 -11
- data/lib/polyfill/v2_4/dir/class/empty_q.rb +0 -23
- data/lib/polyfill/v2_4/enumerable/instance.rb +0 -15
- data/lib/polyfill/v2_4/enumerable/instance/chunk.rb +0 -48
- data/lib/polyfill/v2_4/enumerable/instance/sum.rb +0 -52
- data/lib/polyfill/v2_4/enumerable/instance/uniq.rb +0 -45
- data/lib/polyfill/v2_4/enumerator/lazy/instance.rb +0 -15
- data/lib/polyfill/v2_4/enumerator/lazy/instance/chunk_while.rb +0 -29
- data/lib/polyfill/v2_4/enumerator/lazy/instance/uniq.rb +0 -33
- data/lib/polyfill/v2_4/file/class.rb +0 -11
- data/lib/polyfill/v2_4/file/class/empty_q.rb +0 -23
- data/lib/polyfill/v2_4/float/instance.rb +0 -15
- data/lib/polyfill/v2_4/float/instance/ceil.rb +0 -32
- data/lib/polyfill/v2_4/float/instance/floor.rb +0 -32
- data/lib/polyfill/v2_4/float/instance/truncate.rb +0 -32
- data/lib/polyfill/v2_4/hash/instance.rb +0 -17
- data/lib/polyfill/v2_4/hash/instance/compact.rb +0 -23
- data/lib/polyfill/v2_4/hash/instance/compact_e.rb +0 -23
- data/lib/polyfill/v2_4/hash/instance/transform_values.rb +0 -33
- data/lib/polyfill/v2_4/hash/instance/transform_values_e.rb +0 -33
- data/lib/polyfill/v2_4/i_p_addr/instance.rb +0 -13
- data/lib/polyfill/v2_4/i_p_addr/instance/equalequal.rb +0 -27
- data/lib/polyfill/v2_4/i_p_addr/instance/lessthanequalgreaterthan.rb +0 -27
- data/lib/polyfill/v2_4/integer/instance.rb +0 -19
- data/lib/polyfill/v2_4/integer/instance/ceil.rb +0 -28
- data/lib/polyfill/v2_4/integer/instance/digits.rb +0 -34
- data/lib/polyfill/v2_4/integer/instance/floor.rb +0 -28
- data/lib/polyfill/v2_4/integer/instance/round.rb +0 -31
- data/lib/polyfill/v2_4/integer/instance/truncate.rb +0 -28
- data/lib/polyfill/v2_4/io/class.rb +0 -13
- data/lib/polyfill/v2_4/io/class/foreach.rb +0 -55
- data/lib/polyfill/v2_4/io/class/readlines.rb +0 -37
- data/lib/polyfill/v2_4/io/instance.rb +0 -19
- data/lib/polyfill/v2_4/io/instance/each_line.rb +0 -54
- data/lib/polyfill/v2_4/io/instance/gets.rb +0 -37
- data/lib/polyfill/v2_4/io/instance/lines.rb +0 -54
- data/lib/polyfill/v2_4/io/instance/readline.rb +0 -37
- data/lib/polyfill/v2_4/io/instance/readlines.rb +0 -37
- data/lib/polyfill/v2_4/match_data/instance.rb +0 -13
- data/lib/polyfill/v2_4/match_data/instance/named_captures.rb +0 -25
- data/lib/polyfill/v2_4/match_data/instance/values_at.rb +0 -25
- data/lib/polyfill/v2_4/numeric/instance.rb +0 -17
- data/lib/polyfill/v2_4/numeric/instance/clone.rb +0 -23
- data/lib/polyfill/v2_4/numeric/instance/dup.rb +0 -23
- data/lib/polyfill/v2_4/numeric/instance/finite_q.rb +0 -23
- data/lib/polyfill/v2_4/numeric/instance/infinite_q.rb +0 -23
- data/lib/polyfill/v2_4/object/instance.rb +0 -11
- data/lib/polyfill/v2_4/object/instance/clone.rb +0 -29
- data/lib/polyfill/v2_4/pathname/instance.rb +0 -11
- data/lib/polyfill/v2_4/pathname/instance/empty_q.rb +0 -29
- data/lib/polyfill/v2_4/regexp/instance.rb +0 -11
- data/lib/polyfill/v2_4/regexp/instance/match_q.rb +0 -23
- data/lib/polyfill/v2_4/string/class.rb +0 -11
- data/lib/polyfill/v2_4/string/class/new.rb +0 -26
- data/lib/polyfill/v2_4/string/instance.rb +0 -23
- data/lib/polyfill/v2_4/string/instance/casecmp_q.rb +0 -23
- data/lib/polyfill/v2_4/string/instance/concat.rb +0 -30
- data/lib/polyfill/v2_4/string/instance/each_line.rb +0 -17
- data/lib/polyfill/v2_4/string/instance/lines.rb +0 -55
- data/lib/polyfill/v2_4/string/instance/match_q.rb +0 -23
- data/lib/polyfill/v2_4/string/instance/prepend.rb +0 -30
- data/lib/polyfill/v2_4/string/instance/unpack1.rb +0 -23
- data/lib/polyfill/v2_4/string_io/instance.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/each_line.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/gets.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/readline.rb +0 -17
- data/lib/polyfill/v2_4/string_io/instance/readlines.rb +0 -17
- data/lib/polyfill/v2_4/symbol/instance.rb +0 -15
- data/lib/polyfill/v2_4/symbol/instance/casecmp_q.rb +0 -25
- data/lib/polyfill/v2_4/symbol/instance/match.rb +0 -27
- data/lib/polyfill/v2_4/symbol/instance/match_q.rb +0 -17
data/lib/polyfill/utils.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
module Polyfill
|
2
2
|
module Utils
|
3
|
-
def
|
4
|
-
|
3
|
+
def ignore_warnings
|
4
|
+
orig = $VERBOSE
|
5
|
+
$VERBOSE = nil
|
6
|
+
|
7
|
+
yield
|
8
|
+
|
9
|
+
$VERBOSE = orig
|
5
10
|
end
|
6
|
-
module_function :
|
11
|
+
module_function :ignore_warnings
|
7
12
|
end
|
8
13
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Polyfill
|
2
|
+
module V2_2
|
3
|
+
module Enumerable
|
4
|
+
def slice_after(pattern = nil)
|
5
|
+
raise ArgumentError, 'both pattern and block are given' if pattern && block_given?
|
6
|
+
raise ArgumentError, 'wrong number of arguments (given 0, expected 1)' if !pattern && !block_given?
|
7
|
+
|
8
|
+
matcher = pattern || ::Proc.new
|
9
|
+
enum_count =
|
10
|
+
begin
|
11
|
+
size
|
12
|
+
rescue NameError
|
13
|
+
count
|
14
|
+
end
|
15
|
+
|
16
|
+
::Enumerator.new do |yielder|
|
17
|
+
output = []
|
18
|
+
run = 1
|
19
|
+
each do |element, *rest|
|
20
|
+
elements = rest.any? ? [element, *rest] : element
|
21
|
+
|
22
|
+
output.push(elements)
|
23
|
+
if matcher === elements || run == enum_count # rubocop:disable Style/CaseEquality
|
24
|
+
yielder << output
|
25
|
+
output = []
|
26
|
+
end
|
27
|
+
|
28
|
+
run += 1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/polyfill/v2_3.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative 'v2_3/array'
|
|
2
2
|
require_relative 'v2_3/hash'
|
3
3
|
require_relative 'v2_3/enumerable'
|
4
4
|
require_relative 'v2_3/enumerator/lazy'
|
5
|
+
require_relative 'v2_3/kernel'
|
5
6
|
require_relative 'v2_3/string'
|
6
7
|
require_relative 'v2_3/struct'
|
7
8
|
|
@@ -11,6 +12,7 @@ module Polyfill
|
|
11
12
|
include Hash
|
12
13
|
include Enumerable
|
13
14
|
include Enumerator::Lazy
|
15
|
+
include Kernel
|
14
16
|
include String
|
15
17
|
include Struct
|
16
18
|
end
|
data/lib/polyfill/v2_3/array.rb
CHANGED
@@ -1,9 +1,28 @@
|
|
1
|
-
require_relative 'array/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_3
|
5
3
|
module Array
|
6
|
-
|
4
|
+
def dig(head, *rest)
|
5
|
+
[head, *rest].reduce(self) do |value, accessor|
|
6
|
+
next_value =
|
7
|
+
case value
|
8
|
+
when ::Array
|
9
|
+
value.at(accessor)
|
10
|
+
when ::Hash
|
11
|
+
value[accessor]
|
12
|
+
when ::Struct
|
13
|
+
value[accessor] if value.members.include?(accessor)
|
14
|
+
else
|
15
|
+
begin
|
16
|
+
break value.dig(*rest)
|
17
|
+
rescue NoMethodError
|
18
|
+
raise TypeError, "#{value.class} does not have a #dig method"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
break nil if next_value.nil?
|
23
|
+
next_value
|
24
|
+
end
|
25
|
+
end
|
7
26
|
end
|
8
27
|
end
|
9
28
|
end
|
@@ -1,9 +1,54 @@
|
|
1
|
-
require_relative 'enumerable/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_3
|
5
3
|
module Enumerable
|
6
|
-
|
4
|
+
def chunk_while
|
5
|
+
block = ::Proc.new
|
6
|
+
|
7
|
+
enum_count =
|
8
|
+
begin
|
9
|
+
size
|
10
|
+
rescue NameError
|
11
|
+
count
|
12
|
+
end
|
13
|
+
|
14
|
+
return [self] if enum_count == 1
|
15
|
+
|
16
|
+
::Enumerator.new do |yielder|
|
17
|
+
output = []
|
18
|
+
each_cons(2).with_index(1) do |(a, b), run|
|
19
|
+
if run == enum_count - 1
|
20
|
+
if block.call(a, b)
|
21
|
+
output.push(a, b)
|
22
|
+
yielder << output
|
23
|
+
else
|
24
|
+
output.push(a)
|
25
|
+
yielder << output
|
26
|
+
yielder << [b]
|
27
|
+
end
|
28
|
+
else
|
29
|
+
output.push(a)
|
30
|
+
unless block.call(a, b)
|
31
|
+
yielder << output
|
32
|
+
output = []
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def grep_v(pattern)
|
40
|
+
output = to_a - grep(pattern)
|
41
|
+
output.map!(&::Proc.new) if block_given?
|
42
|
+
output
|
43
|
+
end
|
44
|
+
|
45
|
+
def slice_before(*args)
|
46
|
+
if !args.empty? && block_given?
|
47
|
+
raise ArgumentError, 'wrong number of arguments (given 1, expected 0)'
|
48
|
+
end
|
49
|
+
|
50
|
+
super
|
51
|
+
end
|
7
52
|
end
|
8
53
|
end
|
9
54
|
end
|
@@ -1,10 +1,14 @@
|
|
1
|
-
require_relative 'lazy/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_3
|
5
3
|
module Enumerator
|
6
4
|
module Lazy
|
7
|
-
|
5
|
+
def grep_v(pattern)
|
6
|
+
::Enumerator::Lazy.new(self) do |yielder, element|
|
7
|
+
next if pattern === element # rubocop:disable Style/CaseEquality
|
8
|
+
|
9
|
+
yielder << (block_given? ? yield(element) : element)
|
10
|
+
end
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
data/lib/polyfill/v2_3/hash.rb
CHANGED
@@ -1,9 +1,45 @@
|
|
1
|
-
require_relative 'hash/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_3
|
5
3
|
module Hash
|
6
|
-
|
4
|
+
def dig(head, *rest)
|
5
|
+
[head, *rest].reduce(self) do |value, accessor|
|
6
|
+
next_value =
|
7
|
+
case value
|
8
|
+
when ::Array
|
9
|
+
value.at(accessor)
|
10
|
+
when ::Hash
|
11
|
+
value[accessor]
|
12
|
+
when ::Struct
|
13
|
+
value[accessor] if value.members.include?(accessor)
|
14
|
+
else
|
15
|
+
begin
|
16
|
+
break value.dig(*rest)
|
17
|
+
rescue NoMethodError
|
18
|
+
raise TypeError, "#{value.class} does not have a #dig method"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
break nil if next_value.nil?
|
23
|
+
next_value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def fetch_values(*keys)
|
28
|
+
keys.each_with_object([]) do |key, values|
|
29
|
+
value =
|
30
|
+
if block_given?
|
31
|
+
fetch(key, &::Proc.new)
|
32
|
+
else
|
33
|
+
fetch(key)
|
34
|
+
end
|
35
|
+
|
36
|
+
values << value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_proc
|
41
|
+
method(:[]).to_proc
|
42
|
+
end
|
7
43
|
end
|
8
44
|
end
|
9
45
|
end
|
data/lib/polyfill/v2_3/string.rb
CHANGED
@@ -1,11 +1,29 @@
|
|
1
|
-
require_relative 'string/class'
|
2
|
-
require_relative 'string/instance'
|
3
|
-
|
4
1
|
module Polyfill
|
5
2
|
module V2_3
|
6
3
|
module String
|
7
|
-
|
8
|
-
|
4
|
+
module ClassMethods
|
5
|
+
def new(*args)
|
6
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
7
|
+
hash = hash.first
|
8
|
+
encoding = hash && hash.delete(:encoding)
|
9
|
+
|
10
|
+
if hash && !hash.keys.empty?
|
11
|
+
raise ArgumentError, "unknown keyword: #{hash.keys.first}"
|
12
|
+
end
|
13
|
+
|
14
|
+
str = super(*others)
|
15
|
+
str.encode!(encoding) if encoding
|
16
|
+
str
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def +@
|
21
|
+
frozen? ? dup : self
|
22
|
+
end
|
23
|
+
|
24
|
+
def -@
|
25
|
+
frozen? ? self : dup.freeze
|
26
|
+
end
|
9
27
|
end
|
10
28
|
end
|
11
29
|
end
|
data/lib/polyfill/v2_3/struct.rb
CHANGED
@@ -1,9 +1,28 @@
|
|
1
|
-
require_relative 'struct/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_3
|
5
3
|
module Struct
|
6
|
-
|
4
|
+
def dig(head, *rest)
|
5
|
+
[head, *rest].reduce(self) do |value, accessor|
|
6
|
+
next_value =
|
7
|
+
case value
|
8
|
+
when ::Array
|
9
|
+
value.at(accessor)
|
10
|
+
when ::Hash
|
11
|
+
value[accessor]
|
12
|
+
when ::Struct
|
13
|
+
value[accessor] if value.members.include?(accessor)
|
14
|
+
else
|
15
|
+
begin
|
16
|
+
break value.dig(*rest)
|
17
|
+
rescue NoMethodError
|
18
|
+
raise TypeError, "#{value.class} does not have a #dig method"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
break nil if next_value.nil?
|
23
|
+
next_value
|
24
|
+
end
|
25
|
+
end
|
7
26
|
end
|
8
27
|
end
|
9
28
|
end
|
data/lib/polyfill/v2_4/array.rb
CHANGED
@@ -1,9 +1,31 @@
|
|
1
|
-
require_relative 'array/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Array
|
6
|
-
|
4
|
+
def concat(*others)
|
5
|
+
return super if others.length == 1
|
6
|
+
|
7
|
+
acc = [].concat(self)
|
8
|
+
others.each do |other|
|
9
|
+
acc.concat(other)
|
10
|
+
end
|
11
|
+
|
12
|
+
replace(acc)
|
13
|
+
end
|
14
|
+
|
15
|
+
def sum(init = 0)
|
16
|
+
acc =
|
17
|
+
begin
|
18
|
+
init.dup
|
19
|
+
rescue TypeError
|
20
|
+
init
|
21
|
+
end
|
22
|
+
|
23
|
+
each do |elem|
|
24
|
+
acc += block_given? ? yield(elem) : elem
|
25
|
+
end
|
26
|
+
|
27
|
+
acc
|
28
|
+
end
|
7
29
|
end
|
8
30
|
end
|
9
31
|
end
|
@@ -1,9 +1,15 @@
|
|
1
|
-
require_relative 'comparable/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Comparable
|
6
|
-
|
4
|
+
def clamp(min, max)
|
5
|
+
if min > max
|
6
|
+
raise ArgumentError, 'min argument must be smaller than max argument'
|
7
|
+
end
|
8
|
+
|
9
|
+
return min if min > self
|
10
|
+
return max if max < self
|
11
|
+
self
|
12
|
+
end
|
7
13
|
end
|
8
14
|
end
|
9
15
|
end
|
data/lib/polyfill/v2_4/dir.rb
CHANGED
@@ -1,9 +1,34 @@
|
|
1
|
-
require_relative 'enumerable/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Enumerable
|
6
|
-
|
4
|
+
def chunk(*)
|
5
|
+
return enum_for(:chunk) unless block_given?
|
6
|
+
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def sum(init = 0)
|
11
|
+
acc =
|
12
|
+
begin
|
13
|
+
init.dup
|
14
|
+
rescue TypeError
|
15
|
+
init
|
16
|
+
end
|
17
|
+
|
18
|
+
each do |elem|
|
19
|
+
acc += block_given? ? yield(elem) : elem
|
20
|
+
end
|
21
|
+
|
22
|
+
acc
|
23
|
+
end
|
24
|
+
|
25
|
+
def uniq
|
26
|
+
if block_given?
|
27
|
+
to_a.uniq(&::Proc.new)
|
28
|
+
else
|
29
|
+
to_a.uniq
|
30
|
+
end
|
31
|
+
end
|
7
32
|
end
|
8
33
|
end
|
9
34
|
end
|
@@ -1,10 +1,22 @@
|
|
1
|
-
require_relative 'lazy/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Enumerator
|
6
4
|
module Lazy
|
7
|
-
|
5
|
+
using Polyfill(Enumerable: %w[#chunk_while])
|
6
|
+
|
7
|
+
def chunk_while
|
8
|
+
super.lazy
|
9
|
+
end
|
10
|
+
|
11
|
+
def uniq
|
12
|
+
seen = Set.new
|
13
|
+
|
14
|
+
::Enumerator::Lazy.new(self) do |yielder, *values|
|
15
|
+
result = block_given? ? yield(*values) : values
|
16
|
+
|
17
|
+
yielder.<<(*values) if seen.add?(result)
|
18
|
+
end
|
19
|
+
end
|
8
20
|
end
|
9
21
|
end
|
10
22
|
end
|