lib/enumerator.fy in fancy-0.8.0 vs lib/enumerator.fy in fancy-0.9.0
- old
+ new
@@ -1,7 +1,15 @@
class Fancy {
class Enumerator {
+ class Generator {
+ def initialize: @block
+
+ def each: block {
+ @block call: [block]
+ }
+ }
+
def initialize: @collection {
"""
@collection Collection to iterate over.
Initializes a new Enumerator with a given @collection,
@@ -139,10 +147,12 @@
return self
}
}
}
+ include: Fancy Enumerable
+
def chunk: block {
Generator new: |inner_block| {
enums = []
last = nil
previous = nil
@@ -167,20 +177,13 @@
self
} . to_enum
}
- class Generator {
- def initialize: @block {}
-
- def each: block {
- @block call: [block]
- }
- }
-
def to_a {
output = []
each: |element| { output << element }
+ rewind
output
}
}
}
\ No newline at end of file