Processes the argument list, determining the meaning of each argument and allowing polymorphic argument lists. (See #initialize).
Source Code
# File net/ssh/session.rb, line 205 def process_arguments( *args ) @options = {} @username = ENV['USER'] || ENV['USERNAME'] raise ArgumentError, "you must specify the host to connect to" if args.length < 1 @host = args.shift # support for both named arguments, and positional arguments... if args.length == 1 && args[0].is_a?( Hash ) && ( args[0][:username] || args[0][:password] || args[0][:port] || args[0][:options] ) # then @username = args[0][:username] || @username @password = args[0][:password] @options.update args.shift else @options[ :port ] = args.shift if args.first.is_a? Numeric if args.first.nil? || args.first.is_a?( String ) @username = args.shift || @username end if args.first.nil? || args.first.is_a?( String ) @password = args.shift end @options.update args.shift if args.first.is_a?( Hash ) end if !args.empty? raise ArgumentError, "extra parameters detected: #{args.inspect}" elsif @username.nil? raise ArgumentError, "no username was given and none could be inferred from the environment" end @keys = @options[ :keys ] @host_keys = @options[ :host_keys ] @auth_methods = @options[ :auth_methods ] @forward_agent = @options[ :forward_agent ] || false @crypto_backend = @options.fetch( :crypto_backend, :ossl ) @host_key_verifier = host_key_verifier_from(@options.fetch(:paranoid, true)) verbose = @options.fetch( :verbose, :warn ) log = @options.fetch( :log, STDERR ) @registry_options = @options.fetch( :registry_options, {} ) @registry_options[ :logs ] ||= {} @registry_options[ :logs ][ :default_level ] = verbose if log.is_a? IO @registry_options[ :logs ][ :device ] ||= log else @registry_options[ :logs ][ :filename ] ||= log end @registry = @options[ :container ] || Needle::Registry.new( @registry_options ) [ :keys, :host_keys, :auth_methods, :username, :password, :crypto_backend, :registry_options, :container, :log, :verbose, :forward_agent, :paranoid ].each do |i| @options.delete i end @options.freeze end
<code/>and<pre/>for code samples.