class Snapit::Engine
Attributes
storage[R]
width[R]
Public Class Methods
new(storage, width)
click to toggle source
# File lib/snapit/engine.rb, line 8 def initialize(storage, width) @storage = storage @width = width end
run(storage, width = 1280) { |engine| ... }
click to toggle source
# File lib/snapit/engine.rb, line 13 def self.run(storage, width = 1280) begin engine = new(storage, width) yield engine ensure engine.stop! end end
Public Instance Methods
capture!(url, name_or_idx)
click to toggle source
# File lib/snapit/engine.rb, line 26 def capture!(url, name_or_idx) driver.get(url) driver.save_screenshot("#{storage.output_path.join(name_or_idx)}.png") end
output_path()
click to toggle source
# File lib/snapit/engine.rb, line 22 def output_path end
stop!()
click to toggle source
# File lib/snapit/engine.rb, line 31 def stop! driver.quit end
Private Instance Methods
driver()
click to toggle source
# File lib/snapit/engine.rb, line 37 def driver return @driver if @driver @driver = Selenium::WebDriver.for :firefox @driver.manage.window.resize_to(width, 3000) @driver end