Class: Yummi::Colorizers::StripeColorizer

Inherits:
Object
  • Object
show all
Includes:
Yummi::Colorizer
Defined in:
lib/yummi/colorizers.rb

Overview

A colorizer that cycles through colors to create a striped effect

Instance Method Summary collapse

Methods included from Yummi::Colorizer

#color_for, #colorize

Constructor Details

#initialize(*colors) ⇒ StripeColorizer

Creates a new colorizer using the given colors



342
343
344
345
346
# File 'lib/yummi/colorizers.rb', line 342

def initialize (*colors)
  @colors = colors.flatten
  @colors = [nil] if @colors.empty?
  @count = -1
end

Instance Method Details

#call(*args) ⇒ Object



348
349
350
351
# File 'lib/yummi/colorizers.rb', line 348

def call(*args)
  @count += 1
  @colors[@count % @colors.size]
end