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

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

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.

Instance Method Summary collapse

Methods included from Enumerable

#uniq

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:

  • (ArgumentError)

282
283
284
285
286
# File 'lib/puppet/pops/types/iterable.rb', line 282

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.


288
289
290
291
292
293
294
295
296
297
298
# File 'lib/puppet/pops/types/iterable.rb', line 288

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.


300
301
302
303
# File 'lib/puppet/pops/types/iterable.rb', line 300

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.


305
306
307
# File 'lib/puppet/pops/types/iterable.rb', line 305

def size
  super / @step_size
end