Class: Pdfmdclean

Inherits:
Pdfmd
  • Object
show all
Defined in:
lib/pdfmd/pdfmdclean.rb

Overview

Class: pdfmdclean

Clean metadata from a document

Instance Attribute Summary collapse

Attributes inherited from Pdfmd

#logfile, #logstatus

Instance Method Summary collapse

Methods inherited from Pdfmd

#check_metatags, #metadata, #readUserInput, #read_metatags

Methods included from Pdfmdmethods

#determineValidSetting, #log, #queryHiera

Constructor Details

#initialize(filename) ⇒ Pdfmdclean

Returns a new instance of Pdfmdclean.



9
10
11
# File 'lib/pdfmd/pdfmdclean.rb', line 9

def initialize(filename)
  super(filename)
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/pdfmd/pdfmdclean.rb', line 7

def filename
  @filename
end

#tagsObject

Returns the value of attribute tags.



7
8
9
# File 'lib/pdfmd/pdfmdclean.rb', line 7

def tags
  @tags
end

Instance Method Details

#runObject

Run the actual cleaning



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pdfmd/pdfmdclean.rb', line 14

def run()

  # Figure out which tags actually to reset.
  if @tags.nil? or @tags == 'all'
    @tags = @@default_tags
  elsif @tags.is_a?(String)
    @tags = @tags.split(',')
  end

  # Create the command to delete all the metatags
  command   = 'exiftool'
  parameter = ' -overwrite_original'
  @tags.each do |current_tag|
    parameter << " -#{current_tag}="
  end
  parameter << ' ' 

  `#{command} #{parameter} #{@filename}`
  self.log('info', "Cleaning tags '#{@tags.join(', ').to_s}' from file '#{@filename}'.")
end