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/v2_4/file.rb
CHANGED
data/lib/polyfill/v2_4/float.rb
CHANGED
@@ -1,9 +1,44 @@
|
|
1
|
-
require_relative 'float/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Float
|
6
|
-
|
4
|
+
def ceil(ndigits = 0)
|
5
|
+
ndigits = ndigits.to_int
|
6
|
+
return super() if ndigits == 0
|
7
|
+
|
8
|
+
if ndigits > 0
|
9
|
+
place = 10**ndigits
|
10
|
+
(self * place).ceil / place.to_f
|
11
|
+
else
|
12
|
+
place = 10**-ndigits
|
13
|
+
(self / place).ceil * place
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def floor(ndigits = 0)
|
18
|
+
ndigits = ndigits.to_int
|
19
|
+
return super() if ndigits == 0
|
20
|
+
|
21
|
+
if ndigits > 0
|
22
|
+
place = 10**ndigits
|
23
|
+
(self * place).floor / place.to_f
|
24
|
+
else
|
25
|
+
place = 10**-ndigits
|
26
|
+
(self / place).floor * place
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def truncate(ndigits = 0)
|
31
|
+
ndigits = ndigits.to_int
|
32
|
+
return super() if ndigits == 0
|
33
|
+
|
34
|
+
if ndigits > 0
|
35
|
+
place = 10**ndigits
|
36
|
+
(self * place).truncate / place.to_f
|
37
|
+
else
|
38
|
+
place = 10**-ndigits
|
39
|
+
(self / place).truncate * place
|
40
|
+
end
|
41
|
+
end
|
7
42
|
end
|
8
43
|
end
|
9
44
|
end
|
data/lib/polyfill/v2_4/hash.rb
CHANGED
@@ -1,9 +1,41 @@
|
|
1
|
-
require_relative 'hash/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Hash
|
6
|
-
|
4
|
+
def compact
|
5
|
+
reject { |_, v| v.nil? }
|
6
|
+
end
|
7
|
+
|
8
|
+
def compact!
|
9
|
+
reject! { |_, v| v.nil? }
|
10
|
+
end
|
11
|
+
|
12
|
+
def transform_values
|
13
|
+
unless block_given?
|
14
|
+
return ::Enumerator.new(keys.size) do |yielder|
|
15
|
+
each_with_object({}) do |(k, v), acc|
|
16
|
+
acc[k] = yielder.yield(v)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
each_with_object({}) do |(k, v), acc|
|
22
|
+
acc[k] = yield(v)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def transform_values!
|
27
|
+
unless block_given?
|
28
|
+
return ::Enumerator.new(keys.size) do |yielder|
|
29
|
+
replace(each_with_object({}) do |(k, v), acc|
|
30
|
+
acc[k] = yielder.yield(v)
|
31
|
+
end)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
replace(each_with_object({}) do |(k, v), acc|
|
36
|
+
acc[k] = yield(v)
|
37
|
+
end)
|
38
|
+
end
|
7
39
|
end
|
8
40
|
end
|
9
41
|
end
|
@@ -1,9 +1,59 @@
|
|
1
|
-
require_relative 'integer/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Integer
|
6
|
-
|
4
|
+
def ceil(ndigits = 0)
|
5
|
+
ndigits = ndigits.to_int
|
6
|
+
return super() if ndigits == 0
|
7
|
+
return to_f if ndigits > 0
|
8
|
+
|
9
|
+
place = 10**-ndigits
|
10
|
+
(to_f / place).ceil * place
|
11
|
+
end
|
12
|
+
|
13
|
+
def digits(base = 10)
|
14
|
+
base = base.to_int
|
15
|
+
raise Math::DomainError, 'out of domain' if self < 0
|
16
|
+
raise ArgumentError, 'negative radix' if base < 0
|
17
|
+
raise ArgumentError, "invalid radix #{base}" if base < 2
|
18
|
+
|
19
|
+
acc = []
|
20
|
+
remainder = self
|
21
|
+
while remainder > 0
|
22
|
+
remainder, value = remainder.divmod(base)
|
23
|
+
acc.push(value)
|
24
|
+
end
|
25
|
+
acc
|
26
|
+
end
|
27
|
+
|
28
|
+
def floor(ndigits = 0)
|
29
|
+
ndigits = ndigits.to_int
|
30
|
+
return super() if ndigits == 0
|
31
|
+
return to_f if ndigits > 0
|
32
|
+
|
33
|
+
place = 10**-ndigits
|
34
|
+
(to_f / place).floor * place
|
35
|
+
end
|
36
|
+
|
37
|
+
def round(ndigits = 0, half: nil)
|
38
|
+
unless [nil, :down, :even, :up, 'down', 'even', 'up'].include?(half)
|
39
|
+
raise ArgumentError, "invalid rounding mode: #{half}"
|
40
|
+
end
|
41
|
+
ndigits = ndigits.to_int
|
42
|
+
return super() if ndigits == 0
|
43
|
+
return to_f if ndigits > 0
|
44
|
+
|
45
|
+
place = 10**-ndigits
|
46
|
+
(to_f / place).round * place
|
47
|
+
end
|
48
|
+
|
49
|
+
def truncate(ndigits = 0)
|
50
|
+
ndigits = ndigits.to_int
|
51
|
+
return super() if ndigits == 0
|
52
|
+
return to_f if ndigits > 0
|
53
|
+
|
54
|
+
place = 10**-ndigits
|
55
|
+
(to_f / place).truncate * place
|
56
|
+
end
|
7
57
|
end
|
8
58
|
end
|
9
59
|
end
|
data/lib/polyfill/v2_4/io.rb
CHANGED
@@ -1,11 +1,173 @@
|
|
1
|
-
|
2
|
-
require_relative 'io/instance'
|
1
|
+
require 'English'
|
3
2
|
|
4
3
|
module Polyfill
|
5
4
|
module V2_4
|
6
5
|
module IO
|
7
|
-
|
8
|
-
|
6
|
+
module ClassMethods
|
7
|
+
def foreach(name, *args)
|
8
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
9
|
+
chomps = hash[0] && hash[0][:chomp]
|
10
|
+
|
11
|
+
unless block_given?
|
12
|
+
return super(name, *others) unless chomps
|
13
|
+
|
14
|
+
separator = others.find do |other|
|
15
|
+
other.respond_to?(:to_str)
|
16
|
+
end || $INPUT_RECORD_SEPARATOR
|
17
|
+
|
18
|
+
return ::Enumerator.new do |yielder|
|
19
|
+
super(name, *others) do |line|
|
20
|
+
yielder.yield(line.chomp(separator))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
block =
|
26
|
+
if chomps
|
27
|
+
separator = others.find do |other|
|
28
|
+
other.respond_to?(:to_str)
|
29
|
+
end || $INPUT_RECORD_SEPARATOR
|
30
|
+
|
31
|
+
proc do |line|
|
32
|
+
yield(line.chomp(separator))
|
33
|
+
end
|
34
|
+
else
|
35
|
+
::Proc.new
|
36
|
+
end
|
37
|
+
|
38
|
+
super(name, *others, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def readlines(file_name, *args)
|
42
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
43
|
+
|
44
|
+
inputs = super(file_name, *others)
|
45
|
+
|
46
|
+
if hash[0] && hash[0][:chomp]
|
47
|
+
separator = others.find do |other|
|
48
|
+
other.respond_to?(:to_str)
|
49
|
+
end || $INPUT_RECORD_SEPARATOR
|
50
|
+
|
51
|
+
inputs.each { |input| input.chomp!(separator) }
|
52
|
+
end
|
53
|
+
|
54
|
+
inputs
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def each_line(*args)
|
59
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
60
|
+
chomps = hash[0] && hash[0][:chomp]
|
61
|
+
|
62
|
+
unless block_given?
|
63
|
+
return super(*others) unless chomps
|
64
|
+
|
65
|
+
separator = others.find do |other|
|
66
|
+
other.respond_to?(:to_str)
|
67
|
+
end || $INPUT_RECORD_SEPARATOR
|
68
|
+
return ::Enumerator.new do |yielder|
|
69
|
+
super(*others) do |line|
|
70
|
+
yielder.yield(line.chomp(separator))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
block =
|
76
|
+
if chomps
|
77
|
+
separator = others.find do |other|
|
78
|
+
other.respond_to?(:to_str)
|
79
|
+
end || $INPUT_RECORD_SEPARATOR
|
80
|
+
|
81
|
+
proc do |line|
|
82
|
+
yield(line.chomp(separator))
|
83
|
+
end
|
84
|
+
else
|
85
|
+
::Proc.new
|
86
|
+
end
|
87
|
+
|
88
|
+
super(*others, &block)
|
89
|
+
end
|
90
|
+
|
91
|
+
def gets(*args)
|
92
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
93
|
+
|
94
|
+
input = super(*others)
|
95
|
+
|
96
|
+
if !input.nil? && hash[0] && hash[0][:chomp]
|
97
|
+
separator = others.find do |other|
|
98
|
+
other.respond_to?(:to_str)
|
99
|
+
end || $INPUT_RECORD_SEPARATOR
|
100
|
+
|
101
|
+
input.chomp!(separator)
|
102
|
+
end
|
103
|
+
|
104
|
+
input
|
105
|
+
end
|
106
|
+
|
107
|
+
def lines(*args)
|
108
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
109
|
+
chomps = hash[0] && hash[0][:chomp]
|
110
|
+
|
111
|
+
unless block_given?
|
112
|
+
return super(*others) unless chomps
|
113
|
+
|
114
|
+
separator = others.find do |other|
|
115
|
+
other.respond_to?(:to_str)
|
116
|
+
end || $INPUT_RECORD_SEPARATOR
|
117
|
+
return ::Enumerator.new do |yielder|
|
118
|
+
super(*others) do |line|
|
119
|
+
yielder.yield(line.chomp(separator))
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
block =
|
125
|
+
if chomps
|
126
|
+
separator = others.find do |other|
|
127
|
+
other.respond_to?(:to_str)
|
128
|
+
end || $INPUT_RECORD_SEPARATOR
|
129
|
+
|
130
|
+
proc do |line|
|
131
|
+
yield(line.chomp(separator))
|
132
|
+
end
|
133
|
+
else
|
134
|
+
::Proc.new
|
135
|
+
end
|
136
|
+
|
137
|
+
super(*others, &block)
|
138
|
+
end
|
139
|
+
|
140
|
+
def readline(*args)
|
141
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
142
|
+
|
143
|
+
input = super(*others)
|
144
|
+
|
145
|
+
if hash[0] && hash[0][:chomp]
|
146
|
+
separator = others.find do |other|
|
147
|
+
other.respond_to?(:to_str)
|
148
|
+
end || $INPUT_RECORD_SEPARATOR
|
149
|
+
|
150
|
+
input.chomp!(separator)
|
151
|
+
end
|
152
|
+
|
153
|
+
input
|
154
|
+
end
|
155
|
+
|
156
|
+
def readlines(*args)
|
157
|
+
hash, others = args.partition { |arg| arg.is_a?(::Hash) }
|
158
|
+
|
159
|
+
inputs = super(*others)
|
160
|
+
|
161
|
+
if hash[0] && hash[0][:chomp]
|
162
|
+
separator = others.find do |other|
|
163
|
+
other.respond_to?(:to_str)
|
164
|
+
end || $INPUT_RECORD_SEPARATOR
|
165
|
+
|
166
|
+
inputs.each { |input| input.chomp!(separator) }
|
167
|
+
end
|
168
|
+
|
169
|
+
inputs
|
170
|
+
end
|
9
171
|
end
|
10
172
|
end
|
11
173
|
end
|
@@ -1,9 +1,17 @@
|
|
1
|
-
require_relative 'match_data/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module MatchData
|
6
|
-
|
4
|
+
def named_captures
|
5
|
+
names.each_with_object({}) do |name, acc|
|
6
|
+
acc[name] = self[name]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def values_at(*indexes)
|
11
|
+
indexes.each_with_object([]) do |index, acc|
|
12
|
+
acc.push(self[index])
|
13
|
+
end
|
14
|
+
end
|
7
15
|
end
|
8
16
|
end
|
9
17
|
end
|
@@ -1,9 +1,21 @@
|
|
1
|
-
require_relative 'numeric/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Numeric
|
6
|
-
|
4
|
+
def clone(freeze: true) # rubocop:disable Lint/UnusedMethodArgument
|
5
|
+
self
|
6
|
+
end
|
7
|
+
|
8
|
+
def dup
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def finite?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def infinite?
|
17
|
+
nil
|
18
|
+
end
|
7
19
|
end
|
8
20
|
end
|
9
21
|
end
|
data/lib/polyfill/v2_4/object.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
-
require_relative 'object/instance'
|
2
|
-
|
3
1
|
module Polyfill
|
4
2
|
module V2_4
|
5
3
|
module Object
|
6
|
-
|
4
|
+
def clone(freeze: true)
|
5
|
+
return super() if freeze
|
6
|
+
|
7
|
+
cloned = dup
|
8
|
+
(singleton_class.ancestors - self.class.ancestors).drop(1).each do |ancestor|
|
9
|
+
cloned.extend(ancestor)
|
10
|
+
end
|
11
|
+
cloned
|
12
|
+
end
|
7
13
|
end
|
8
14
|
end
|
9
15
|
end
|