# File lib/net/ssh/connection/channel.rb, line 218
    def request_pty(opts={}, &block)
      extra = opts.keys - VALID_PTY_OPTIONS.keys
      raise ArgumentError, "invalid option(s) to request_pty: #{extra.inspect}" if extra.any?

      opts = VALID_PTY_OPTIONS.merge(opts)

      modes = opts[:modes].inject(Buffer.new) do |memo, (mode, data)|
        memo.write_byte(mode).write_long(data)
      end
      # mark the end of the mode opcode list with a 0 byte
      modes.write_byte(0)

      send_channel_request("pty-req", :string, opts[:term],
        :long, opts[:chars_wide], :long, opts[:chars_high],
        :long, opts[:pixels_wide], :long, opts[:pixels_high],
        :string, modes.to_s, &block)
    end