Permalink
Browse files

Change Lazy class outer

Lazy class should be under Enumerator instead of Enumerable
  • Loading branch information...
ksss committed Nov 30, 2016
1 parent 2bb47ad commit 0f90227907b15f879319600cfa523be5928c5da9
View
@@ -53,7 +53,7 @@ MRuby::GemBox.new do |conf|
# Use Enumerator class (require mruby-fiber)
conf.gem :core => "mruby-enumerator"
# Use Enumerable::Lazy class (require mruby-enumerator)
# Use Enumerator::Lazy class (require mruby-enumerator)
conf.gem :core => "mruby-enum-lazy"
# Use toplevel object (main) methods extension
@@ -1,7 +1,7 @@
MRuby::Gem::Specification.new('mruby-enum-lazy') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Enumerable::Lazy class'
spec.summary = 'Enumerator::Lazy class'
spec.add_dependency('mruby-enumerator', :core => 'mruby-enumerator')
spec.add_dependency('mruby-enum-ext', :core => 'mruby-enum-ext')
end
@@ -2,7 +2,7 @@ module Enumerable
# = Enumerable#lazy implementation
#
# Enumerable#lazy returns an instance of Enumerable::Lazy.
# Enumerable#lazy returns an instance of Enumerator::Lazy.
# You can use it just like as normal Enumerable object,
# except these methods act as 'lazy':
#
@@ -16,9 +16,11 @@ module Enumerable
# - flat_map collect_concat
# - zip
def lazy
Lazy.new(self)
Enumerator::Lazy.new(self)
end
end
class Enumerator
# == Acknowledgements
#
# Based on https://github.com/yhara/enumerable-lazy
@@ -1,9 +1,9 @@
assert("Enumerable::Lazy") do
assert("Enumerator::Lazy") do
a = [1, 2]
assert_equal Enumerable::Lazy, a.lazy.class
assert_equal Enumerator::Lazy, a.lazy.class
end
assert("Enumerable::Lazy laziness") do
assert("Enumerator::Lazy laziness") do
a = Object.new
def a.each
return to_enum :each unless block_given?
@@ -40,7 +40,7 @@ def a.b(b=nil)
assert_equal [10,20], a.b
end
assert("Enumerable::Lazy#zip with cycle") do
assert("Enumerator::Lazy#zip with cycle") do
e1 = [1, 2, 3].cycle
e2 = [:a, :b].cycle
assert_equal [[1,:a],[2,:b],[3,:a]], e1.lazy.zip(e2).first(3)

0 comments on commit 0f90227

Please sign in to comment.