Class: Pdfmult::PDFInfo
- Inherits:
-
Object
- Object
- Pdfmult::PDFInfo
- Defined in:
- lib/pdfmult.rb
Overview
A class for PDF meta data (up to now only used for the page count).
Create an instance with PDFInfo.new, specifying the file name. PDFInfo tries to use the pdfinfo system tool to obtain meta data. If successful, the attribute page_count contains the page count, else the attribute is set to nil.
Constant Summary collapse
- PDFINFOCMD =
"/usr/bin/pdfinfo"
Instance Attribute Summary collapse
-
#page_count ⇒ Object
readonly
Returns the page count of the input file, or nil.
Class Method Summary collapse
-
.infocmd_available? ⇒ Boolean
Returns true if default
pdfinfosystem tool is available (for unit tests).
Instance Method Summary collapse
-
#initialize(file, options = {}) ⇒ PDFInfo
constructor
This is the initialization method for the class.
Constructor Details
#initialize(file, options = {}) ⇒ PDFInfo
This is the initialization method for the class.
file - file name of the PDF file
262 263 264 265 266 267 |
# File 'lib/pdfmult.rb', line 262 def initialize(file, = {}) @file = file @binary = [:pdfinfocmd] || PDFINFOCMD # for unit tests infos = retrieve_infos @page_count = infos["Pages"]&.to_i end |
Instance Attribute Details
#page_count ⇒ Object (readonly)
Returns the page count of the input file, or nil.
257 258 259 |
# File 'lib/pdfmult.rb', line 257 def page_count @page_count end |
Class Method Details
.infocmd_available? ⇒ Boolean
Returns true if default pdfinfo system tool is available (for unit tests).
270 271 272 |
# File 'lib/pdfmult.rb', line 270 def self.infocmd_available? Application.command_available?("#{PDFINFOCMD} -v") end |