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

#element_type, #method_missing, #respond_to_missing?, #step, #step_iterator, #to_s, #unbounded?

Methods included from Iterable

asserted_iterable, #each, #element_type, 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



225
226
227
228
229
# File 'lib/puppet/pops/types/iterable.rb', line 225

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



231
232
233
234
235
236
237
238
239
240
241
# File 'lib/puppet/pops/types/iterable.rb', line 231

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



243
244
245
246
# File 'lib/puppet/pops/types/iterable.rb', line 243

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



248
249
250
# File 'lib/puppet/pops/types/iterable.rb', line 248

def size
  super / @step_size
end