class Mutool
Constants
- VERSION
Attributes
has_mutool[RW]
mutool_path[RW]
Public Class Methods
clean(input, output, pages='1-N', ops)
click to toggle source
mupdf.com/docs/manual-mutool-clean.html
# File lib/mutool.rb, line 29 def clean(input, output, pages='1-N', ops) raise 'mutool not found' unless has_mutool? run([mutool_path, 'clean', flags(ops), input, output, pages].flatten) end
convert(input, pages='1-N', ops)
click to toggle source
Reference: mupdf.com/docs/manual-mutool-convert.html
# File lib/mutool.rb, line 23 def convert(input, pages='1-N', ops) raise 'mutool not found' unless has_mutool? run([mutool_path, 'convert', flags(ops), input, pages].flatten) end
flags(ops = {})
click to toggle source
# File lib/mutool.rb, line 13 def flags(ops = {}) ops.map { |key, value| ["-#{key}", value] } end
has_mutool?()
click to toggle source
# File lib/mutool.rb, line 9 def has_mutool? @has_mutool ||= run([mutool_path]).exitstatus == 1 end
version()
click to toggle source
# File lib/mutool.rb, line 17 def version raise 'mutool not found' unless has_mutool? @version ||= version_str.gsub("\n", '').split(' ').last end
Private Class Methods
run(command = [])
click to toggle source
# File lib/mutool.rb, line 46 def run(command = []) system(*command, out: File::NULL, err: File::NULL) $? end
version_str()
click to toggle source
# File lib/mutool.rb, line 36 def version_str _, _, stderr, thread = Open3.popen3('mutool -v') thread.join stderr.read end