class FormatParser::PDFParser
Constants
- PDF_CONTENT_TYPE
- PDF_MARKER
First 9 bytes of a PDF should be in this format, according to:
https://stackoverflow.com/questions/3108201/detect-if-pdf-file-is-correct-header-pdf
There are however exceptions, which are left out for now.
Public Instance Methods
call(io)
click to toggle source
# File lib/parsers/pdf_parser.rb, line 16 def call(io) io = FormatParser::IOConstraint.new(io) return unless safe_read(io, 9) =~ PDF_MARKER FormatParser::Document.new(format: :pdf, content_type: PDF_CONTENT_TYPE) end
likely_match?(filename)
click to toggle source
# File lib/parsers/pdf_parser.rb, line 12 def likely_match?(filename) filename =~ /\.(pdf|ai)$/i end