Class: WinRM::Transport::ShellCloser

Inherits:
Object
  • Object
show all
Defined in:
lib/winrm/transport/shell_closer.rb

Overview

An object that can close a remote shell session over WinRM.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info, debug, args) ⇒ ShellCloser

Constructs a new ShellCloser.

Parameters:

  • info (String)

    a string representation of the connection

  • debug (true, false)

    whether or not debug messages should be output

  • args (Array)

    arguments to construct a ‘WinRM::WinRMWebService`



38
39
40
41
42
# File 'lib/winrm/transport/shell_closer.rb', line 38

def initialize(info, debug, args)
  @info = info
  @debug = debug
  @args = args
end

Instance Attribute Details

#shell_idString?

Returns the identifier for the current open remote shell session.

Returns:

  • (String, nil)

    the identifier for the current open remote shell session



30
31
32
# File 'lib/winrm/transport/shell_closer.rb', line 30

def shell_id
  @shell_id
end

Instance Method Details

#callObject

Closes the remote shell session.



45
46
47
48
49
50
51
# File 'lib/winrm/transport/shell_closer.rb', line 45

def call(*)
  debug("[CommandExecutor] closing remote shell #{@shell_id} on #{@info}")
  ::WinRM::WinRMWebService.new(*@args).close_shell(@shell_id)
  debug("[CommandExecutor] remote shell #{@shell_id} closed")
rescue => e
  debug("Exception: #{e.inspect}")
end

#for(shell_id) ⇒ ShellCloser

Returns a new ShellCloser with a copy of this object’s state and the shell_id set to the given parameter value.

Parameters:

  • shell_id (String)

    a remote shell ID

Returns:

  • (ShellCloser)

    a new ShellCloser with a copy of this object’s state and the shell_id set to the given parameter value



56
57
58
# File 'lib/winrm/transport/shell_closer.rb', line 56

def for(shell_id)
  self.class.new(@info, @debug, @args).tap { |c| c.shell_id = shell_id }
end