class DjVused

Interface to djvused.

Attributes

command[RW]
file[R]

Public Class Methods

new(file) click to toggle source

@see DjVused#new

# File lib/djvu-tools/djvused.rb, line 8
def initialize file
  raise SystemCallError, 'djvused command not found' if ( Which::which 'djvused' ).empty?

  @file = File.expand_path file
  raise RuntimeError, 'File not found' unless ( File.exists? @file )
  @command = ""
end

Public Instance Methods

save() click to toggle source

Runs djvused with command and saves to file.

# File lib/djvu-tools/djvused.rb, line 28
def save
  system *['djvused', '-s','-e', @command, @file]
end
title_page(page, title) click to toggle source

Appends command to set page title. @param [Integer] page number @param [String] title cannot contain single or double quotes @return [String] command string

# File lib/djvu-tools/djvused.rb, line 20
def title_page page, title
  raise ArgumentError, 'Argument is not an integer' unless page.is_a? Integer
  raise ArgumentError, 'Argument is cannot contain a single or double quote' if title =~ /['"]/

  @command << %Q{select #{page}; set-page-title "#{title}";}
end