Class: Preflight::Rules::PageBoxHeight
- Inherits:
-
Object
- Object
- Preflight::Rules::PageBoxHeight
- Includes:
- Measurements
- Defined in:
- lib/preflight/rules/page_box_height.rb
Overview
Ensure the requested page box (MediaBox, TrimBox, etc) on every page has the requested height. Dimensions can be in points, mm or inches. Skips the page if the requested box isn’t defined, it’s up to other rules to check for the existence of the box.
Arguments: the target page box, the target height and the the units
Usage:
class MyPreflight
include Preflight::Profile
rule Preflight::Rules::PageBoxHeight, :MediaBox, 100, :mm
rule Preflight::Rules::PageBoxHeight, :TrimBox, 600, :pts
rule Preflight::Rules::PageBoxHeight, :CropBox, 5, :in
rule Preflight::Rules::PageBoxHeight, :MediaBox, 100..101, :mm
rule Preflight::Rules::PageBoxHeight, :TrimBox, 600..700, :pts
rule Preflight::Rules::PageBoxHeight, :CropBox, 5..6, :in
end
Instance Attribute Summary collapse
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
Instance Method Summary collapse
-
#initialize(box, height, units) ⇒ PageBoxHeight
constructor
A new instance of PageBoxHeight.
- #page=(page) ⇒ Object
Constructor Details
#initialize(box, height, units) ⇒ PageBoxHeight
Returns a new instance of PageBoxHeight.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/preflight/rules/page_box_height.rb', line 31 def initialize(box, height, units) @box, @units = box, units @orig_height = height @height = case units when :mm then mm_to_points(height) when :in then inches_to_points(height) else points_to_points(height) end end |
Instance Attribute Details
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
29 30 31 |
# File 'lib/preflight/rules/page_box_height.rb', line 29 def issues @issues end |
Instance Method Details
#page=(page) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/preflight/rules/page_box_height.rb', line 42 def page=(page) @issues = [] dict = page.attributes if dict[@box] box_height = dict[@box][3] - dict[@box][1] if !@height.include?(box_height) @issues << Issue.new("#{@box} height must be #{@orig_height}#{@units}", self, :page => page.number, :box => @box, :height => @orig_height, :units => @units) end end end |