Class: Preflight::Rules::RootHasKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/preflight/rules/root_has_keys.rb

Overview

Every PDF has a ‘Root’ dictionary, check that the target file has certain keys in it’s Root

Arguments: the required keys

Usage:

class MyPreflight
  include Preflight::Profile

  rule Preflight::Rules::RootHasKeys, :OutputIntents
end

Instance Method Summary collapse

Constructor Details

#initialize(*keys) ⇒ RootHasKeys

Returns a new instance of RootHasKeys.



21
22
23
# File 'lib/preflight/rules/root_has_keys.rb', line 21

def initialize(*keys)
  @keys = keys.flatten
end

Instance Method Details

#check_hash(ohash) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/preflight/rules/root_has_keys.rb', line 25

def check_hash(ohash)
  root = ohash.object(ohash.trailer[:Root])
  missing = @keys - root.keys
  missing.map { |key|
    Issue.new("Root dict missing required key #{key}", self, :key => key)
  }
end