lib/squib/layout_parser.rb in squib-0.13.4 vs lib/squib/layout_parser.rb in squib-0.14.beta1
- old
+ new
@@ -32,11 +32,11 @@
private
# Determine the file path of the built-in layout file
def builtin(file)
- "#{File.dirname(__FILE__)}/layouts/#{file}"
+ "#{File.dirname(__FILE__)}/builtin/layouts/#{file}"
end
# Process the extends recursively
# :nodoc:
# @api private
@@ -51,10 +51,14 @@
from_extends = yml[key].merge(recurse_extends(yml, parent_key, visited)) do |key, child_val, parent_val|
if child_val.to_s.strip.start_with?('+=')
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?('*=')
+ 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
end
h = h.merge(from_extends) do |key, older_sibling, younger_sibling|
@@ -72,9 +76,21 @@
def sub_parent_child(parent, child)
parent_pixels = Args::UnitConversion.parse(parent, @dpi).to_f
child_pixels = Args::UnitConversion.parse(child.sub('-=', ''), @dpi).to_f
parent_pixels - child_pixels
+ end
+
+ def mul_parent_child(parent, child)
+ parent_pixels = Args::UnitConversion.parse(parent, @dpi).to_f
+ child_float = child.sub('*=', '').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: