summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-enum-chain/mrblib
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2019-07-28 22:52:24 +0900
committerKOBAYASHI Shuji <[email protected]>2019-07-28 22:52:24 +0900
commit7f80a5f73cb3823e562f37c12a25d6d43d9b512d (patch)
treeec9fae12150fce7c0aef54e68d4150e891516191 /mrbgems/mruby-enum-chain/mrblib
parent04a422e4998b289b44d227936bd4203ede08bd40 (diff)
downloadmruby-7f80a5f73cb3823e562f37c12a25d6d43d9b512d.tar.gz
mruby-7f80a5f73cb3823e562f37c12a25d6d43d9b512d.zip
Define `#+` to `Enumerator` and `Enumerator#Chain` instead of `Enumerable`
Diffstat (limited to 'mrbgems/mruby-enum-chain/mrblib')
-rw-r--r--mrbgems/mruby-enum-chain/mrblib/chain.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/mrbgems/mruby-enum-chain/mrblib/chain.rb b/mrbgems/mruby-enum-chain/mrblib/chain.rb
index 52f5f0656..03acfb7ef 100644
--- a/mrbgems/mruby-enum-chain/mrblib/chain.rb
+++ b/mrbgems/mruby-enum-chain/mrblib/chain.rb
@@ -6,13 +6,13 @@ module Enumerable
def chain(*args)
Enumerator::Chain.new(self, *args)
end
+end
+class Enumerator
def +(other)
- Enumerator::Chain.new(self, other)
+ Chain.new(self, other)
end
-end
-class Enumerator
class Chain
include Enumerable
@@ -50,6 +50,10 @@ class Enumerator
self
end
+ def +(other)
+ self.class.new(self, other)
+ end
+
def inspect
"#<#{self.class}: #{@enums.inspect}>"
end