Module: PdfMatcher::PdfFile

Defined in:
lib/pdf_matcher/pdf_file.rb

Defined Under Namespace

Classes: Base, File, Tempfile

Class Method Summary collapse

Class Method Details

.init(path_or_data) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pdf_matcher/pdf_file.rb', line 7

def self.init(path_or_data)
  case path_or_data
  # when a pdf path passed as a Pathname
  when Pathname
    File.new(path_or_data)
  when String
    # when a pdf data passed
    if path_or_data =~ /^%PDF-/
      Tempfile.new(path_or_data)
    # when a pdf path passed
    else
      File.new(path_or_data)
    end
  else
    raise ArgumentError
  end
end