starting documenting xywh_shorthands

This commit is contained in:
Andy Meneely
2020-11-17 22:22:38 -05:00
parent 82afdf1608
commit b304bf39e4
8 changed files with 77 additions and 10 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ module Squib
when /deg$/ # ends with "deg"
arg.rstrip[0..-3].to_f * (Math::PI / 180.0)
when /c(ell)?[s]?$/ # ends with 'c', 'cell', or 'cells'
arg.rstrip[0..-2].to_f * cell_px
arg.sub(/c(ell)?[s]?$/, '').to_f * cell_px
else
arg
end
+4 -3
View File
@@ -7,7 +7,6 @@ module Squib
HEIGHT_MINUS_REGEX = /^height\s*\-\s*/
WIDTH_DIV_REGEX = /^width\s*\/\s*/
HEIGHT_DIV_REGEX = /^height\s*\/\s*/
CELL_REGEX = /^c[ell]?[s]?\s*/
MIDDLE_PLUS_REGEX = /^middle\s*\+\s*/
MIDDLE_MINUS_REGEX = /^middle\s*\-\s*/
@@ -32,10 +31,12 @@ module Squib
n = UnitConversion.parse(n)
deck.height - n
when WIDTH_DIV_REGEX # e.g. width / 3
n = (arg_s.sub WIDTH_DIV_REGEX, '').to_f
n = arg_s.sub WIDTH_DIV_REGEX, ''
n = UnitConversion.parse(n).to_f
deck.width / n
when HEIGHT_DIV_REGEX # e.g. height / 3
n = (arg_s.sub HEIGHT_DIV_REGEX, '').to_f
n = arg_s.sub HEIGHT_DIV_REGEX, ''
n = UnitConversion.parse(n).to_f
deck.height / n
when MIDDLE_PLUS_REGEX # e.g. middle + 1.5in
n = arg_s.sub MIDDLE_PLUS_REGEX, ''