Sha256: c14885866139d516908aa51fc8067af76b9bedf803b2b35d118d7b9f328386e3
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
module ChromedriverScreenshot class Row def self.from_boundaries(boundaries) row_ary = [] boundaries.inject(0) do |row_top, row_bottom| row_ary << new(row_top, row_bottom) row_bottom end row_ary end def screenshot tiles = @tiles.map { |tile| tile.screenshot } return tiles.first if tiles.count == 1 row_width = tiles.inject(0) do |width, tile| width += tile.width end row_height = tiles.first.height # assume all tiles have same height screenshot = ChunkyPNG::Image.new(row_width, row_height) (1..row_height).each do |row| new_row = tiles.inject([]) do |concatenated_row, tile| concatenated_row += tile.row(row - 1) end screenshot.replace_row!(row - 1, new_row) end screenshot end private def initialize(row_top, row_bottom) bounds = column_boundaries @tiles = Tile.from_boundaries(row_top, row_bottom, column_boundaries) end def column_boundaries column_boundary_ary = [] platform = ChromedriverScreenshot::Platforms.platform new_boundary = platform.window_width while new_boundary < platform.page_width column_boundary_ary << new_boundary new_boundary += platform.window_width end column_boundary_ary << platform.page_width end end end
Version data entries
3 entries across 3 versions & 1 rubygems