Class: DjVused
- Inherits:
-
Object
- Object
- DjVused
- Defined in:
- lib/djvu-tools/djvused.rb
Overview
Interface to djvused.
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(file) ⇒ DjVused
constructor
A new instance of DjVused.
-
#save ⇒ Object
Runs djvused with command and saves to file.
-
#title_page(page, title) ⇒ String
Appends command to set page title.
Constructor Details
#initialize(file) ⇒ DjVused
Returns a new instance of DjVused.
8 9 10 11 12 13 14 |
# File 'lib/djvu-tools/djvused.rb', line 8 def initialize file raise SystemCallError, 'djvused command not found' if ( Which::which 'djvused' ).empty? @file = File. file raise RuntimeError, 'File not found' unless ( File.exists? @file ) @command = "" end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
5 6 7 |
# File 'lib/djvu-tools/djvused.rb', line 5 def command @command end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/djvu-tools/djvused.rb', line 4 def file @file end |
Instance Method Details
#save ⇒ Object
Runs djvused with command and saves to file.
28 29 30 |
# File 'lib/djvu-tools/djvused.rb', line 28 def save system *['djvused', '-s','-e', @command, @file] end |
#title_page(page, title) ⇒ String
Appends command to set page title.
20 21 22 23 24 25 |
# 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 |