Class: Swatches::SwatchGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/swatches/swatch_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_color, color_name) ⇒ SwatchGenerator

Returns a new instance of SwatchGenerator.



8
9
10
11
# File 'lib/swatches/swatch_generator.rb', line 8

def initialize(base_color, color_name)
  @tint_calculator = TintCalculator.new(base_color)
  @color_name = color_name
end

Instance Method Details

#to_sassObject



13
14
15
16
17
18
19
20
21
# File 'lib/swatches/swatch_generator.rb', line 13

def to_sass
  output = ""
  0.upto(50).each do |i|
    lightness = i*2
    color = @tint_calculator.generate_color_for_lightness(lightness)
    output << "$#{@color_name}-#{lightness}: #{color.inspect};\n"
  end
  output
end