Class: Monet::Capture
- Inherits:
-
Object
- Object
- Monet::Capture
- Includes:
- Capybara::DSL
- Defined in:
- lib/monet/capture.rb
Constant Summary collapse
- MAX_HEIGHT =
10000
Instance Method Summary collapse
- #capture(url, image_or_save_path) ⇒ Object
- #capture_all ⇒ Object
-
#initialize(config) ⇒ Capture
constructor
A new instance of Capture.
Constructor Details
#initialize(config) ⇒ Capture
Returns a new instance of Capture.
16 17 18 19 20 21 |
# File 'lib/monet/capture.rb', line 16 def initialize(config) @config = config @router = Monet::Router.new config .default_driver = @config.driver end |
Instance Method Details
#capture(url, image_or_save_path) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/monet/capture.rb', line 39 def capture(url, image_or_save_path) if image_or_save_path.is_a? String image = Monet::Image.new image_or_save_path else image = image_or_save_path end visit_once url page.driver.resize(image.width, MAX_HEIGHT) page.driver.render(image.path, full: true) image.thumbnail!(@router.thumbnail_dir) if @config.thumbnail? end |
#capture_all ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/monet/capture.rb', line 23 def capture_all images = [] @router.capture_routes.map do |url, paths| visit_once url paths.each do |path| image = Monet::Image.new path capture(url, image) images << image end end images end |