Module: CLSX

Defined in:
lib/clsx.rb,
lib/clsx/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.clsx(*args) ⇒ Object



9
10
11
# File 'lib/clsx.rb', line 9

def self.clsx(*args)
  args.flat_map { |arg| parse(arg) }.compact.join(" ")
end

.parse(arg) ⇒ Object



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

def self.parse(arg)
  case arg
  when String
    arg unless arg.empty?
  when Hash
    arg.map { |k, v| k if v }.compact
  when Array
    arg.flat_map { |a| parse(a) }
  end
end