You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
392 B
21 lines
392 B
require 'squib/constants' |
|
|
|
module Squib |
|
module Args |
|
module UnitConversion |
|
|
|
module_function |
|
def parse(arg, dpi=300) |
|
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 |
|
|
|
end |
|
end |
|
end |