Class: Stevedore::Pdf::Metadata
- Inherits:
-
Object
- Object
- Stevedore::Pdf::Metadata
- Defined in:
- lib/stevedore/pdf.rb
Instance Method Summary collapse
-
#initialize(pdf) ⇒ Metadata
constructor
A new instance of Metadata.
- #num_pages ⇒ Object
- #page_size ⇒ Object
Constructor Details
#initialize(pdf) ⇒ Metadata
Returns a new instance of Metadata.
23 24 25 26 27 28 29 30 31 |
# File 'lib/stevedore/pdf.rb', line 23 def initialize(pdf) @pdf = pdf output = Stevedore.run("pdfinfo #{@pdf.file_path}") @raw_metadata = output.split("\n").reduce(Hash.new) do |, line| name, val = line.split(/: +/,2) [name] = val end end |
Instance Method Details
#num_pages ⇒ Object
33 34 35 |
# File 'lib/stevedore/pdf.rb', line 33 def num_pages @raw_metadata["Pages"].to_i end |
#page_size ⇒ Object
37 38 39 40 |
# File 'lib/stevedore/pdf.rb', line 37 def page_size size_data = @raw_metadata["Page size"].split(' ') [size_data[0].to_i, size_data[2].to_i] end |