Sha256: 110d7c4aac16e81f649b27786b2351e935e0a58a8bedee0353f95bc753c6ef79

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

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 = path(type)
      FileUtils::mkdir_p(File.dirname(@path)) unless File.exists?(@path)
      @image.write @path
      @path
    end

    def exists?
      File.exists?(path)
    end

    def path type = :reference
      @path = File.join(Gatling::Configuration.path(type), @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(path).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.9 lib/gatling/image.rb