class BreezyPDF::HTML::Strip
Replace assets with uploaded URL's
Public Class Methods
new(html_fragment)
click to toggle source
# 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
Public Instance Methods
stripped_fragment()
click to toggle source
# 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
timing()
click to toggle source
# File lib/breezy_pdf/html/strip.rb, line 18 def timing @timing ||= Process.clock_gettime(Process::CLOCK_MONOTONIC) - @start_time end
Private Instance Methods
parsed_document()
click to toggle source
# File lib/breezy_pdf/html/strip.rb, line 31 def parsed_document @parsed_document ||= Nokogiri::HTML(@html_fragment) end
strip!()
click to toggle source
# File lib/breezy_pdf/html/strip.rb, line 24 def strip! BreezyPDF.filter_elements_selectors.each do |selector| BreezyPDF.logger.info("[BreezyPDF] Stripping out elements matching selector `#{selector}`") parsed_document.css(selector).each(&:remove) end end