Sha256: bcbb696941214724c0c020d892b198024147c973de54c8357894a27b023cfa75

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 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 XcodeVersion.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

1 entries across 1 versions & 1 rubygems

Version Path
simctl-1.5.8 lib/simctl/command/io.rb