class Net::SSH::Script::Script
Net::SSH::Command wrapper to work with multiple commands.
Public Class Methods
[](commands)
click to toggle source
# File lib/net/ssh/script.rb, line 9 def self.[](commands) new commands end
new(commands)
click to toggle source
# File lib/net/ssh/script.rb, line 13 def initialize(commands) if commands.is_a? String @_commands = [Command[commands]] elsif commands.is_a?(Array) && commands.all? { |cmd| cmd.is_a? String } @_commands = commands.map { |c| Command[c] } elsif commands.is_a?(Array) && commands.all? { |cmd| cmd.is_a? Command } @_commands = commands else raise 'Invalid script argument.' end end
Public Instance Methods
done?()
click to toggle source
# File lib/net/ssh/script.rb, line 31 def done? @_commands.all?(&:done?) end
inspect()
click to toggle source
# File lib/net/ssh/script.rb, line 47 def inspect @_commands.map(&:inspect).join "\n" end
run(ssh)
click to toggle source
# File lib/net/ssh/script.rb, line 26 def run(ssh) @_commands.each { |cmd| break unless cmd.run(ssh) } ok? end
status()
click to toggle source
# File lib/net/ssh/script.rb, line 35 def status return :pending if @_commands.all?(&:pending?) return :failed if @_commands.any?(&:failed?) return :error if @_commands.any?(&:error?) return :running unless done? :ok end
to_s()
click to toggle source
# File lib/net/ssh/script.rb, line 43 def to_s @_commands.map(&:to_s).join "\n" end