Class: BreezyPDF::Uploads::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/breezy_pdf/uploads/base.rb

Overview

Upload an asset

Instance Method Summary collapse

Constructor Details

#initialize(filename, content_type, file_path) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
# File 'lib/breezy_pdf/uploads/base.rb', line 6

def initialize(filename, content_type, file_path)
  @filename     = filename
  @content_type = content_type
  @file_path    = file_path

  @start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

Instance Method Details

#idObject



26
27
28
# File 'lib/breezy_pdf/uploads/base.rb', line 26

def id
  resource.id
end

#public_urlObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/breezy_pdf/uploads/base.rb', line 14

def public_url
  @start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  BreezyPDF.logger.info(%([BreezyPDF] Starting private asset upload for #{@filename}))
  upload!

  @end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  BreezyPDF.logger.info(
    %([BreezyPDF] Private asset upload for #{@filename} completed in #{timing} seconds)
  )
  resource.presigned_url
end

#timingObject



30
31
32
# File 'lib/breezy_pdf/uploads/base.rb', line 30

def timing
  @timing ||= Process.clock_gettime(Process::CLOCK_MONOTONIC) - @start_time
end