Sha256: 6e0bbe94cab5ead8ef6241a46cf5545475ab30fb2fbfb582daa4e4d31ef5a826
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
module Nakal module Common class BaseScreen attr_accessor :image, :name def initialize file_name, mode = :load, image = nil Nakal.create_image_dir @name = file_name @image = image capture if mode.eql?(:capture) image.nil? ? @image = Magick::Image.read("#{Nakal.image_location}/#{@name}.png")[0] : @image=image end def strip crop_params = Nakal.default_crop_params[Nakal.device_name] if crop_params.nil? @image else width = @image.columns height = @image.rows x_start = crop_params["left"] y_start = crop_params["top"] width_to_consider = width-crop_params["right"]-x_start height_to_consider = height-crop_params["bottom"]-y_start @image.crop(x_start, y_start, width_to_consider, height_to_consider) end end def compare screen diff_img, diff_metric = self.strip.compare_channel(screen.strip, Magick::RootMeanSquaredErrorMetric) diff_screen = Nakal.current_platform::Screen.new("#{@name}_diff", :none, diff_img) return diff_screen, diff_metric end def delete! FileUtils.rm "#{Nakal.image_location}/#{@name}.png" end def save @image.write("#{Nakal.image_location}/#{@name}.png") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nakal-0.0.5 | lib/nakal/base_screen.rb |
nakal-0.0.4 | lib/nakal/base_screen.rb |
nakal-0.0.3 | lib/nakal/base_screen.rb |