Class: MimiCheck::Generator::Carousel

Inherits:
Object
  • Object
show all
Includes:
MimiCheck::Generator
Defined in:
lib/mimicheck/generator/carousel.rb

Instance Method Summary collapse

Methods included from MimiCheck::Generator

#call, #to_proc

Constructor Details

#initialize(*elements) ⇒ Carousel

Returns a new instance of Carousel.



6
7
8
9
# File 'lib/mimicheck/generator/carousel.rb', line 6

def initialize(*elements)
  @elements = elements
  @current = -1
end

Instance Method Details

#generateObject



13
14
15
16
# File 'lib/mimicheck/generator/carousel.rb', line 13

def generate
  return nil unless elements.size.nonzero?
  elements[(@current += 1) % elements.size]
end