Class: PdfMatcher::Matcher
- Inherits:
-
Object
- Object
- PdfMatcher::Matcher
- Defined in:
- lib/pdf_matcher/matcher.rb
Instance Method Summary collapse
-
#initialize(pdf1, pdf2, output_diff: nil, diff_pdf_opts: nil) ⇒ Matcher
constructor
A new instance of Matcher.
- #match ⇒ Object
Constructor Details
#initialize(pdf1, pdf2, output_diff: nil, diff_pdf_opts: nil) ⇒ Matcher
Returns a new instance of Matcher.
9 10 11 12 13 14 |
# File 'lib/pdf_matcher/matcher.rb', line 9 def initialize(pdf1, pdf2, output_diff: nil, diff_pdf_opts: nil) @pdf1 = PdfFile.init(pdf1) @pdf2 = PdfFile.init(pdf2) @output_diff_path = output_diff ? Pathname(output_diff) : nil @diff_pdf_opts = diff_pdf_opts || PdfMatcher.config.diff_pdf_opts end |
Instance Method Details
#match ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pdf_matcher/matcher.rb', line 16 def match @result ||= begin matched = match_pdfs if matched # [NOTE] The diff-pdf command will generate a diff PDF file # regardless of the result if the `--output_diff` option is given. output_diff_path.unlink if output_diff_path&.exist? MatchResult.new(matched, pdf1, pdf2, nil) else MatchResult.new(matched, pdf1, pdf2, output_diff_path) end end end |