Class: Puppet::Pops::Types::StepIterator Private

Inherits:
Iterator show all
Includes:
Enumerable
Defined in:
lib/puppet/pops/types/iterable.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Method Summary collapse

Methods inherited from Iterator

#all?, #any?, #element_type, #map, #method_missing, #reduce, #respond_to_missing?, #step, #step_iterator, #to_s, #unbounded?

Methods included from Iterable

asserted_iterable, #each, #element_type, #hash_style?, on, #step, #to_a, unbounded?, #unbounded?

Constructor Details

#initialize(element_type, enumeration, step_size) ⇒ StepIterator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of StepIterator.

Raises:

API:

  • private



290
291
292
293
294
295
# File 'lib/puppet/pops/types/iterable.rb', line 290

def initialize(element_type, enumeration, step_size)
  super(element_type, enumeration)
  raise ArgumentError if step_size <= 0

  @step_size = step_size
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Puppet::Pops::Types::Iterator

Instance Method Details

#nextObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



297
298
299
300
301
302
303
304
305
306
307
# File 'lib/puppet/pops/types/iterable.rb', line 297

def next
  result = @enumeration.next
  skip = @step_size - 1
  if skip > 0
    begin
      skip.times { @enumeration.next }
    rescue StopIteration
    end
  end
  result
end

#reverse_each(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



309
310
311
312
# File 'lib/puppet/pops/types/iterable.rb', line 309

def reverse_each(&block)
  r = Iterator.new(@element_type, to_a.reverse_each)
  block_given? ? r.each(&block) : r
end

#sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



314
315
316
# File 'lib/puppet/pops/types/iterable.rb', line 314

def size
  super / @step_size
end