Class: TNS::Output::CSS

Inherits:
Object
  • Object
show all
Defined in:
lib/tns/output/css.rb

Overview

Output a given color as CSS property (aka. variable).

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ CSS

Returns a new instance of CSS.



7
8
9
# File 'lib/tns/output/css.rb', line 7

def initialize(name)
  @name = name
end

Instance Method Details

#format(palette) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/tns/output/css.rb', line 11

def format(palette)
  palette
    .map { |variant| format_variant(variant) }
    .map(&:to_s)
    .map { |string| "#{string};" }
    .join("\n")
end

#format_variant(variant) ⇒ Object



19
20
21
# File 'lib/tns/output/css.rb', line 19

def format_variant(variant)
  "--#{@name}-#{variant.index * 100}: #{variant.to_css}"
end