Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created June 14, 2016 20:27
Show Gist options
  • Save ucnv/5881159a6d296e2fbdde48458476d7d9 to your computer and use it in GitHub Desktop.
Save ucnv/5881159a6d296e2fbdde48458476d7d9 to your computer and use it in GitHub Desktop.
#!/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