Class: Fabricators::Generator
- Inherits:
-
Object
- Object
- Fabricators::Generator
- Defined in:
- lib/fabricators/generator.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(starts_at, &block) ⇒ Generator
constructor
A new instance of Generator.
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
#generate ⇒ Object
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 |