lib/squib/args/arg_loader.rb in squib-0.10.0 vs lib/squib/args/arg_loader.rb in squib-0.11.0
- old
+ new
@@ -109,29 +109,17 @@
def convert_units(dpi: 300)
self.class.params_with_units.each do |p|
p_str = "@#{p}"
p_val = instance_variable_get(p_str)
if p_val.respond_to? :each
- arr = p_val.map { |x| convert_unit(x, dpi) }
+ arr = p_val.map { |x| UnitConversion.parse(x, dpi) }
instance_variable_set p_str, arr
else
- instance_variable_set p_str, convert_unit(p_val, dpi)
+ instance_variable_set p_str, UnitConversion.parse(p_val, dpi)
end
end
self
end
-
- def convert_unit(arg, dpi)
- case arg.to_s.rstrip
- when /in$/ # ends with "in"
- arg.rstrip[0..-2].to_f * dpi
- when /cm$/ # ends with "cm"
- arg.rstrip[0..-2].to_f * dpi * INCHES_IN_CM
- else
- arg
- end
- end
- module_function :convert_unit
end
end
end