Class: Preflight::Rules::PageCount
- Inherits:
-
Object
- Object
- Preflight::Rules::PageCount
- Defined in:
- lib/preflight/rules/page_count.rb
Overview
Ensure the page count matches certain criteria.
Arguments: An integer, range, :even or :odd
Usage:
class MyPreflight
include Preflight::Profile
rule Preflight::Rules::PageCount, 1
rule Preflight::Rules::PageCount, 1..2
rule Preflight::Rules::PageCount, [4, 8]
rule Preflight::Rules::PageCount, :even
rule Preflight::Rules::PageCount, :odd
end
Instance Method Summary collapse
- #check_hash(objects) ⇒ Object
-
#initialize(pattern) ⇒ PageCount
constructor
A new instance of PageCount.
Constructor Details
#initialize(pattern) ⇒ PageCount
Returns a new instance of PageCount.
24 25 26 |
# File 'lib/preflight/rules/page_count.rb', line 24 def initialize(pattern) @pattern = pattern end |
Instance Method Details
#check_hash(objects) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/preflight/rules/page_count.rb', line 28 def check_hash(objects) root = objects.deref(objects.trailer[:Root]) pages = objects.deref(root[:Pages]) count = objects.deref(pages[:Count]) case @pattern when Fixnum then check_numeric(count) when Range then check_range(count) when Array then check_array(count) when :even then check_even(count) when :odd then check_odd(count) else [Issue.new("PageCount: invalid pattern", self)] end end |