Sha256: 2fd036a30c0ea2e777308eef6daf9f69f28e043bac2928525ce9af198a335a73

Contents?: true

Size: 923 Bytes

Versions: 5

Compression:

Stored size: 923 Bytes

Contents

# Interface to djvused.
class DjVused

  attr_reader :file
  attr_accessor :command

  # @see DjVused#new
  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

  # Appends command to set page title.
  # @param [Integer] page number
  # @param [String] title cannot contain single or double quotes
  # @return [String] command string
  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

  # Runs djvused with command and saves to file.
  def save
    system *['djvused', '-s','-e', @command, @file]
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
djvu-tools-0.2.2 lib/djvu-tools/djvused.rb
djvu-tools-0.2.1 lib/djvu-tools/djvused.rb
djvu-tools-0.1.1 lib/djvu-tools/djvused.rb
djvu-tools-0.1.0 lib/djvu-tools/djvused.rb
djvu-tools-0.0.1 lib/djvu-tools/djvused.rb