24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/csscss/parser/multi_side_transformer.rb', line 24
def transform_sides(context)
values = [context[:top], context[:right], context[:bottom], context[:left]].compact
case values.size
when 4
%w(top right bottom left).zip(values).map {|side, value| side_declaration(side, value) }
when 3
%w(top right bottom).zip(values).map {|side, value| side_declaration(side, value) }.tap do |declarations|
declarations << side_declaration("left", values[1])
end
when 2
%w(top right).zip(values).map {|side, value| side_declaration(side, value) }.tap do |declarations|
declarations << side_declaration("bottom", values[0])
declarations << side_declaration("left", values[1])
end
when 1
%w(top right bottom left).map do |side|
side_declaration(side, values[0])
end
end
end
|