Module: AnimateIt::Style

Defined in:
lib/animate_it/style.rb

Class Method Summary collapse

Class Method Details

.build(*rules, **properties) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/animate_it/style.rb', line 5

def build(*rules, **properties)
  property_rules = properties.filter_map do |property, value|
    next if value.nil?

    "#{property.to_s.tr("_", "-")}: #{value}"
  end

  (rules.flatten.compact + property_rules).join("; ")
end

.vars(**properties) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/animate_it/style.rb', line 15

def vars(**properties)
  properties.filter_map do |property, value|
    next if value.nil?

    "--#{property.to_s.tr("_", "-")}: #{value}"
  end.join("; ")
end