Created
June 14, 2016 20:27
-
-
Save ucnv/5881159a6d296e2fbdde48458476d7d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'docopt' | |
doc = <<DOCOPT | |
Usage: | |
#{File.basename __FILE__} <dpi> <px> [--verbose] | |
Options: | |
-v --verbose Show numbers after the decimal point. | |
-h --help Show this screen. | |
DOCOPT | |
begin | |
opt = Docopt::docopt(doc) | |
dpi = opt['<dpi>'].to_f | |
px = opt['<px>'].to_f | |
tmp = opt['--verbose'] ? "%f mm" : "%d mm" | |
puts tmp % [25.4 * px / dpi] | |
rescue Docopt::Exit => e | |
puts e.message | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment