Class: Pludoni::Pdfutils::FileWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/pludoni/pdfutils/file_wrapper.rb

Direct Known Subclasses

ActiveStorageWrapper, LocalFileWrapper

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ FileWrapper

Returns a new instance of FileWrapper.



4
5
6
# File 'lib/pludoni/pdfutils/file_wrapper.rb', line 4

def initialize(file)
  @file = file
end

Class Method Details

.make(blob_or_file, filename: nil) ⇒ Object



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

def self.make(blob_or_file, filename: nil)
  case blob_or_file
  when ActiveStorage::Blob
    ActiveStorageWrapper.new(blob_or_file)
  when File, Tempfile
    fw = LocalFileWrapper.new(blob_or_file)
    if filename
      fw.filename = filename
    end
    fw
  when FileWrapper
    blob_or_file
  else
    raise NotImplementedError, blob_or_file.class
  end
end

Instance Method Details

#content_typeObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/pludoni/pdfutils/file_wrapper.rb', line 33

def content_type
  raise NotImplementedError
end

#filesizeObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/pludoni/pdfutils/file_wrapper.rb', line 25

def filesize
  raise NotImplementedError
end

#open(&block) ⇒ Object

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/pludoni/pdfutils/file_wrapper.rb', line 29

def open(&block)
  raise NotImplementedError
end