class Pdfmdedit
Class: pdfmdedit¶ ↑
Edit Metadata of PDF documentsc
Attributes
filename[RW]
opendoc[RW]
pdfviewer[RW]
Public Class Methods
new(filename)
click to toggle source
Calls superclass method
Pdfmd::new
# File lib/pdfmd/pdfmdedit.rb, line 11 def initialize(filename) super(filename) self.set_tags(@@default_tags) end
Public Instance Methods
start_viewer(filename = '', viewer = '')
click to toggle source
Start a viewer
# File lib/pdfmd/pdfmdedit.rb, line 18 def start_viewer(filename = '', viewer = '') if File.exists?(filename) and !viewer.empty? pid = IO.popen("#{viewer} '#{filename}' 2>&1") self.log('debug', "Application '#{viewer}' with PID #{pid.pid} started to show file '#{filename}'.") pid.pid elsif viewer.empty? self.log('error', 'No viewer specified. Aborting document view.') else self.log('error', "Could not find file '#{filename}' for viewing.") end end
validateDate(date)
click to toggle source
Function to validate and interprete date information
# File lib/pdfmd/pdfmdedit.rb, line 171 def validateDate(date) year = '[1-2][90][0-9][0-9]' month = '0[1-9]|10|11|12' day = '[1-9]|0[1-9]|1[0-9]|2[0-9]|3[0-1]' hour = '[0-1][0-9]|2[0-3]|[1-9]' minute = '[0-5][0-9]' second = '[0-5][0-9]' case date when /^(#{year})(#{month})(#{day})$/ identifiedDate = $1 + ':' + $2 + ':' + $3 + ' 00:00:00' when /^(#{year})(#{month})(#{day})(#{hour})(#{minute})(#{second})$/ identifiedDate = $1 + ':' + $2 + ':' + $3 + ' ' + $4 + ':' + $5 + ':' + $6 when /^(#{year})[\:|\.|\-](#{month})[\:|\.|\-](#{day})\s(#{hour})[\:](#{minute})[\:](#{second})$/ identifiedDate = $1 + ':' + $2 + ':' + $3 + ' ' + $4 + ':' + $5 + ':' + $6 when /^(#{year})[\:|\.|\-](#{month})[\:|\.|\-](#{day})$/ day = "%02d" % $3 month = "%02d" % $2 # Return the identified string $1 + ':' + month + ':' + day + ' 00:00:00' else # This wasn't a date we recognize false end end