Class: Mutool

Inherits:
Object
  • Object
show all
Defined in:
lib/mutool.rb,
lib/mutool/version.rb

Constant Summary collapse

VERSION =
'0.1.2'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.has_mutoolObject

Returns the value of attribute has_mutool.



7
8
9
# File 'lib/mutool.rb', line 7

def has_mutool
  @has_mutool
end

.mutool_path=(value) ⇒ Object

Sets the attribute mutool_path

Parameters:

  • value

    the value to set the attribute mutool_path to.



7
8
9
# File 'lib/mutool.rb', line 7

def mutool_path=(value)
  @mutool_path = value
end

Class Method Details

.clean(input, output, pages = '1-N', ops) ⇒ Object



29
30
31
32
# 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) ⇒ Object



23
24
25
26
# 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 = {}) ⇒ Object



13
14
15
# File 'lib/mutool.rb', line 13

def flags(ops = {})
  ops.map { |key, value| ["-#{key}", value] }
end

.has_mutool?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/mutool.rb', line 9

def has_mutool?
  @has_mutool ||= run([mutool_path]).exitstatus == 1
end

.versionObject



17
18
19
20
# File 'lib/mutool.rb', line 17

def version
  raise 'mutool not found' unless has_mutool?
  @version ||= version_str.gsub("\n", '').split(' ').last
end