Class: MirrorMirror::Transformation::BoxShadow

Inherits:
PropertyTransformation show all
Defined in:
lib/mirror-mirror/transformation/box_shadow.rb

Constant Summary collapse

NEGATIVE_ONE =
Sass::Script::Number.new(-1)

Instance Method Summary collapse

Methods inherited from PropertyTransformation

instances, #transform_name, #transform_name?, #transform_value, #transform_value?

Methods inherited from Base

inherited, instances

Instance Method Details

#flip_it(expression) ⇒ Object



23
24
25
26
27
# File 'lib/mirror-mirror/transformation/box_shadow.rb', line 23

def flip_it(expression)
  opts(expression.options) do
    expression.times(NEGATIVE_ONE)
  end
end

#transform_expression(name, expression) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mirror-mirror/transformation/box_shadow.rb', line 9

def transform_expression(name, expression)
  for_each_value(expression) do |e|
    case e
    when Sass::Script::List
      if e.value[0].is_a?(Sass::Script::Number)
        e.value[0] = flip_it(e.value[0])
      end
    when Sass::Script::Number
      e = flip_it(e)
    end
    e
  end
end

#transform_expression?(name) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/mirror-mirror/transformation/box_shadow.rb', line 3

def transform_expression?(name)
  name == "box-shadow"
end