Class: Puppet::Pops::Types::Iterator Private

Inherits:
Object
  • Object
show all
Includes:
Iterable
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.

Direct Known Subclasses

IntegerRangeIterator, StepIterator

Instance Method Summary collapse

Methods included from Iterable

asserted_iterable, #each, on, #to_a, unbounded?

Constructor Details

#initialize(element_type, enumeration) ⇒ Iterator

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 Iterator.



161
162
163
164
# File 'lib/puppet/pops/types/iterable.rb', line 161

def initialize(element_type, enumeration)
  @element_type = element_type
  @enumeration = enumeration
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *arguments, &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.



178
179
180
# File 'lib/puppet/pops/types/iterable.rb', line 178

def method_missing(name, *arguments, &block)
  @enumeration.send(name, *arguments, &block)
end

Instance Method Details

#element_typeObject

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.



166
167
168
# File 'lib/puppet/pops/types/iterable.rb', line 166

def element_type
  @element_type
end

#respond_to_missing?(name, include_private) ⇒ Boolean

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:

  • (Boolean)


174
175
176
# File 'lib/puppet/pops/types/iterable.rb', line 174

def respond_to_missing?(name, include_private)
  @enumeration.respond_to?(name, include_private)
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.



202
203
204
205
# File 'lib/puppet/pops/types/iterable.rb', line 202

def reverse_each(&block)
  r = Iterator.new(@element_type, @enumeration.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.



170
171
172
# File 'lib/puppet/pops/types/iterable.rb', line 170

def size
  @enumeration.size
end

#step(step, &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.

Raises:

  • (ArgumentError)


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/puppet/pops/types/iterable.rb', line 182

def step(step, &block)
  raise ArgumentError if step <= 0
  r = self
  r = r.step_iterator(step) if step > 1

  if block_given?
    begin
    if block.arity == 1
      loop { yield(r.next) }
    else
      loop { yield(*r.next) }
    end
    rescue StopIteration
    end
    self
  else
    r
  end
end

#step_iterator(step) ⇒ 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.



207
208
209
# File 'lib/puppet/pops/types/iterable.rb', line 207

def step_iterator(step)
  StepIterator.new(@element_type, self, step)
end

#to_sObject

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.



211
212
213
214
# File 'lib/puppet/pops/types/iterable.rb', line 211

def to_s
  et = element_type
  et.nil? ? 'Iterator-Value' : "Iterator[#{et.generalize}]-Value"
end

#unbounded?Boolean

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:

  • (Boolean)


216
217
218
# File 'lib/puppet/pops/types/iterable.rb', line 216

def unbounded?
  Iterable.unbounded?(@enumeration)
end