Class: Preflight::Rules::PageBoxWidth
- Inherits:
-
Object
- Object
- Preflight::Rules::PageBoxWidth
- Includes:
- Measurements
- Defined in:
- lib/preflight/rules/page_box_width.rb
Overview
Ensure the requested page box (MediaBox, TrimBox, etc) on every page has the requested width. 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, width, units) ⇒ PageBoxWidth
constructor
A new instance of PageBoxWidth.
- #page=(page) ⇒ Object
Constructor Details
#initialize(box, width, units) ⇒ PageBoxWidth
Returns a new instance of PageBoxWidth.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/preflight/rules/page_box_width.rb', line 31 def initialize(box, width, units) @box, @units = box, units @orig_width = width @width = case units when :mm then mm_to_points(width) when :in then inches_to_points(width) else points_to_points(width) end end |
Instance Attribute Details
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
29 30 31 |
# File 'lib/preflight/rules/page_box_width.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_width.rb', line 42 def page=(page) @issues = [] dict = page.attributes if dict[@box] box_width = dict[@box][2] - dict[@box][0] if !@width.include?(box_width) @issues << Issue.new("#{@box} width must be #{@orig_width}#{@units}", self, :page => page.number, :box => @box, :width => @orig_width, :units => @units) end end end |