Sha256: e7f474ff89aa42d485995990c10573157c5be36fa6833947c92a06470cff7ccf

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Gatling
  class Image

    attr_accessor :file_name, :path, :image

    attr_reader :type

    def initialize image, file_name

      @file_name = file_name

      @image = image

    end

    def save type
      path = Gatling::Configuration.path(type[:as])
      FileUtils::mkdir_p(path) unless File.exists?(path)
      @path = File.join(path, @file_name)
      @image.write @path
      @path
    end

    def exists?
      File.exists?(File.join(Gatling::Configuration.path(:reference), @file_name))
    end

  end

  class ImageFromElement < Image

    def initialize element, file_name
      super(image, file_name)

      @image = Gatling::CaptureElement.new(element).capture
    end
    
    #TODO: make save a relevant subclass method
  end

  class ImageFromFile < Image

    def initialize file_name
      super(image, file_name)

      @image = Magick::Image.read(File.join(Gatling::Configuration.path(:reference), @file_name)).first
    end

    #TODO: make save a relevant subclass method
    
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gatling-1.0.8 lib/gatling/image.rb