add x= and /= to extends values

This commit is contained in:
Clarence "Sparr" Risher
2017-10-05 19:41:43 -04:00
committed by Andy Meneely
parent 2a86b8f215
commit b3bd8f03d8
2 changed files with 22 additions and 4 deletions
+16
View File
@@ -53,6 +53,10 @@ module Squib
add_parent_child(parent_val, child_val)
elsif child_val.to_s.strip.start_with?('-=')
sub_parent_child(parent_val, child_val)
elsif child_val.to_s.strip.start_with?('x=')
mul_parent_child(parent_val, child_val)
elsif child_val.to_s.strip.start_with?('/=')
div_parent_child(parent_val, child_val)
else
child_val # child overrides parent when merging, no +=
end
@@ -76,6 +80,18 @@ module Squib
parent_pixels - child_pixels
end
def mul_parent_child(parent, child)
parent_pixels = Args::UnitConversion.parse(parent, @dpi).to_f
child_float = child.sub('x=', '').to_f
parent_pixels * child_float
end
def div_parent_child(parent, child)
parent_pixels = Args::UnitConversion.parse(parent, @dpi).to_f
child_float = child.sub('/=', '').to_f
parent_pixels / child_float
end
# Does this layout entry have an extends field?
# i.e. is it a base-case or will it need recursion?
# :nodoc: