class PdfSpec::Matchers::IdenticalPdfs
Class that conforms to RSpec specifications for matchers
@param [String] pdf_data PDF content as a Ruby string
Public Class Methods
new(pdf_data)
click to toggle source
# File lib/pdf_spec/matchers.rb, line 7 def initialize(pdf_data) @expected_pages = pdf_to_pixel_pages(pdf_data) end
Public Instance Methods
matches?(pdf_data)
click to toggle source
Compares given PDF data against
@param [String] pdf_data PDF content as a Ruby string
# File lib/pdf_spec/matchers.rb, line 14 def matches?(pdf_data) @target_pages = pdf_to_pixel_pages(pdf_data) @target_pages == @expected_pages end
Private Instance Methods
pdf_to_pixel_pages(pdf_data)
click to toggle source
Get array of page pixels. The first level array represents PDF pages, the second level array - pixels.
@param [String] pdf_data binary string that represents pdf
@return [Array<Array<Integer>>] array of arrays of pixels
# File lib/pdf_spec/matchers.rb, line 33 def pdf_to_pixel_pages(pdf_data) Magick::ImageList.new. from_blob(pdf_data). remap { |page| page.export_pixels } end