Method: Expect4r::BaseLoginObject#initialize
- Defined in:
- lib/misc/base.rb
#initialize(*args) ⇒ BaseLoginObject
@method, host, @user, pwd, enable_pwd, port = args @method, host, @user, pwd, enable_pwd = args @method, host, @user, pwd, port = args @method, host, @user, pwd = args
@method, host+port, @user, pwd, enable_pwd = args @method, host+port, @user, pwd = args
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/misc/base.rb', line 91 def initialize(*args) host, _pwd, _enable_pwd, ciphered_password=[nil]*5 if args.size>2 and args[1].is_a?(String) case args.size when 6 @method, host, @user, _pwd, _enable_pwd, port = args when 5 if args.last.is_a?(Fixnum) @method, host, @user, _pwd, port = args else @method, host, @user, _pwd, _enable_pwd = args end else @method, host, @user, _pwd, port = args end raise ArgumentError if host.split.size>1 and port @host, _port = host.split @port = port || (_port || 0).to_i elsif args.size == 2 and args[1].is_a?(Hash) and args[0].is_a?(Symbol) @method = args[0] @host = args[1][:host] || args[1][:hostname] port = args[1][:port] @port = (port || 0).to_i @user = args[1][:user]|| args[1][:username] _pwd = args[1][:pwd] || args[1][:password] ciphered_password = args[1][:ciphered_password] _enable_pwd = args[1][:enable_password] ciphered_enable_password = args[1][:ciphered_enable_password] else raise end @pwd = if ciphered_password ciphered_password else Expect4r.cipher(_pwd) if _pwd end @enable_pwd = if ciphered_enable_password ciphered_enable_password else Expect4r.cipher(_enable_pwd || _pwd) if _enable_pwd || _pwd end @ps1 = /(.*)(>|#|\$)\s*$/ @more = / --More-- / @matches=Set.new Base.add(self) self end |