Class: RandomSet::CustomGenerator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/random_set/template.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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ CustomGenerator

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



92
93
94
95
# File 'lib/random_set/template.rb', line 92

def initialize(block)
  @block = block
  @iteration = 0
end

Instance Attribute Details

#blockObject (readonly)

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.



97
98
99
# File 'lib/random_set/template.rb', line 97

def block
  @block
end

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.



99
100
101
102
103
104
105
106
107
# File 'lib/random_set/template.rb', line 99

def next
  if block.arity == 1
    block.call @iteration
  else
    block.call
  end
ensure
  @iteration += 1
end