Sha256: 37405f940557e1377deafdfa5e6e424b93be310a86f0beb205d90acbc76f8c63

Contents?: true

Size: 881 Bytes

Versions: 3

Compression:

Stored size: 881 Bytes

Contents

require 'shellwords'

module SimCtl
  class Command
    module IO
      # Saves a screenshot to a file
      #
      # @param device [SimCtl::Device] the device the screenshot should be taken from
      # @param file Path where the screenshot should be saved to
      # @param opts Optional hash that supports two keys:
      # * type: Can be png, tiff, bmp, gif, jpeg (default is png)
      # * display: Can be main or tv for iOS, tv for tvOS and main for watchOS
      # @return [void]
      def screenshot(device, file, opts={})
        unless Xcode::Version.gte? '8.2'
          raise UnsupportedCommandError.new('Needs at least Xcode 8.2')
        end
        optional_args = opts.map {|k,v| "--#{k}=#{Shellwords.shellescape(v)}"}
        Executor.execute(command_for('io', device.udid, 'screenshot', *optional_args, Shellwords.shellescape(file)))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simctl-1.6.2 lib/simctl/command/io.rb
simctl-1.6.1 lib/simctl/command/io.rb
simctl-1.6.0 lib/simctl/command/io.rb