Class: Fabricators::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/fabricators/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(starts_at, &block) ⇒ Generator

Returns a new instance of Generator.



4
5
6
7
# File 'lib/fabricators/generator.rb', line 4

def initialize(starts_at, &block)
  @index = starts_at
  @block = block
end

Instance Method Details

#generateObject



9
10
11
12
13
14
15
16
# File 'lib/fabricators/generator.rb', line 9

def generate
  @index += 1
  if @block
    @block.call(@index)
  else
    @index
  end
end