Sha256: 6b8a411cacdc9d88754b4f28d2228bbcb227cc1ae34e5e70846f32efa2925636

Contents?: true

Size: 705 Bytes

Versions: 2

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

module MkvToolNix
  module Modules

    module MkvModule

      def call_cmd(cmd)
        status, out, err = nil
        Open3.popen3(*cmd) do |_, stdout, stderr, thread|
          out = stdout.read
          err = stderr.read
          status = thread.value
        end

        raise Errors::MkvToolNixError, out if status != 0

        CmdResult.new(out, err, status)
      end

      class CmdResult

        attr_reader :stdout, :stderr, :status

        def initialize(stdout, stderr, status)
          @stdout = stdout
          @stderr = stderr
          @status = status
        end

        def error?
          status != 0
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mkvtoolnix-1.0.0 lib/mkvtoolnix/modules/mkv_module.rb
mkvtoolnix-0.7.0 lib/mkvtoolnix/modules/mkv_module.rb