Class: ShellStrike::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/shell_strike/host.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 22, connection_timeout = 30, actions = []) ⇒ Host

Initialises a new Host object.

Parameters:

  • host (String)

    the hostname or IP address of the host.

  • port (Number) (defaults to: 22)

    the port number to use for the connection.

  • connection_timeout (Number) (defaults to: 30)

    how long to wait before timing out connection attempts (in seconds).

  • actions (Array<String>) (defaults to: [])

    Shell commands to execute against the server, upon successful connection. Interactive commands are NOT supported.



9
10
11
12
13
14
# File 'lib/shell_strike/host.rb', line 9

def initialize(host, port = 22, connection_timeout = 30, actions = [])
  @host = host
  @port = port
  @connection_timeout = connection_timeout
  @actions = actions
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



2
3
4
# File 'lib/shell_strike/host.rb', line 2

def actions
  @actions
end

#connection_timeoutObject (readonly)

Returns the value of attribute connection_timeout.



2
3
4
# File 'lib/shell_strike/host.rb', line 2

def connection_timeout
  @connection_timeout
end

#hostObject (readonly)

Returns the value of attribute host.



2
3
4
# File 'lib/shell_strike/host.rb', line 2

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



2
3
4
# File 'lib/shell_strike/host.rb', line 2

def port
  @port
end

Instance Method Details

#to_uriString

Returns the current host’s address in URI form.

Examples:

192.168.1.200:22
172.20.16.20:200
example.com:22

Returns:

  • (String)

    the current host’s address in URI form. (host:port)



22
23
24
# File 'lib/shell_strike/host.rb', line 22

def to_uri
  "#{self.host}:#{self.port}"
end