Class: BreezyPDF::HTML::Strip

Inherits:
Object
  • Object
show all
Defined in:
lib/breezy_pdf/html/strip.rb

Overview

Replace assets with uploaded URL’s

Instance Method Summary collapse

Constructor Details

#initialize(html_fragment) ⇒ Strip

Returns a new instance of Strip.



6
7
8
9
# File 'lib/breezy_pdf/html/strip.rb', line 6

def initialize(html_fragment)
  @html_fragment = html_fragment
  @start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

Instance Method Details

#stripped_fragmentObject



11
12
13
14
15
16
# File 'lib/breezy_pdf/html/strip.rb', line 11

def stripped_fragment
  @stripped_fragment ||= parsed_document.tap do
    strip!
    BreezyPDF.logger.info("[BreezyPDF] Stripped out elements in `#{timing} seconds`")
  end.to_html
end

#timingObject



18
19
20
# File 'lib/breezy_pdf/html/strip.rb', line 18

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