diff options
author | Bruno Wagner Goncalves <bwagner@thoughtworks.com> | 2014-08-01 17:49:13 -0300 |
---|---|---|
committer | Bruno Wagner Goncalves <bwagner@thoughtworks.com> | 2014-08-01 17:49:13 -0300 |
commit | f52efae271ddb376e7223405c3a74edd7ed598b9 (patch) | |
tree | bf76c588086b93452457c71bdbfa6cee0206c81f /fake-service/lib/pixelated_service/paginated_enumerable.rb | |
parent | d8360815ea07d9944f08ad378d2b89e64e1f2c9e (diff) |
Changed names according to new convention on the fake service
Diffstat (limited to 'fake-service/lib/pixelated_service/paginated_enumerable.rb')
-rw-r--r-- | fake-service/lib/pixelated_service/paginated_enumerable.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/fake-service/lib/pixelated_service/paginated_enumerable.rb b/fake-service/lib/pixelated_service/paginated_enumerable.rb new file mode 100644 index 00000000..b1045e2f --- /dev/null +++ b/fake-service/lib/pixelated_service/paginated_enumerable.rb @@ -0,0 +1,29 @@ + +module PixelatedService + class Paginate + class PaginatedEnumerable + include Enumerable + def initialize(input, start, e) + @input = input + @start = start + @end = e + end + + def each + @input.each_with_index do |v, ix| + if ix >= @end + return #we are done + elsif ix >= @start + yield v + end + end + end + + def each_total + @input.each do |v| + yield v + end + end + end + end +end |