Class: TeradataCli::LogonString
- Inherits:
-
Object
- Object
- TeradataCli::LogonString
- Defined in:
- lib/teradata-cli/utils.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#tdpid ⇒ Object
readonly
Returns the value of attribute tdpid.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tdpid, user, password, account = nil) ⇒ LogonString
constructor
A new instance of LogonString.
- #inspect ⇒ Object
- #safe_string ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(tdpid, user, password, account = nil) ⇒ LogonString
Returns a new instance of LogonString.
28 29 30 31 32 33 |
# File 'lib/teradata-cli/utils.rb', line 28 def initialize(tdpid, user, password, account = nil) @tdpid = tdpid @user = user @password = password @account = account end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
38 39 40 |
# File 'lib/teradata-cli/utils.rb', line 38 def account @account end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
37 38 39 |
# File 'lib/teradata-cli/utils.rb', line 37 def password @password end |
#tdpid ⇒ Object (readonly)
Returns the value of attribute tdpid.
35 36 37 |
# File 'lib/teradata-cli/utils.rb', line 35 def tdpid @tdpid end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
36 37 38 |
# File 'lib/teradata-cli/utils.rb', line 36 def user @user end |
Class Method Details
.intern(arg) ⇒ Object
18 19 20 |
# File 'lib/teradata-cli/utils.rb', line 18 def LogonString.intern(arg) arg.kind_of?(LogonString) ? arg : LogonString.parse(arg.to_s) end |
.parse(str) ⇒ Object
22 23 24 25 26 |
# File 'lib/teradata-cli/utils.rb', line 22 def LogonString.parse(str) m = %r<\A(?:([^/\s]+)/)?(\w+),(\w+)(?:,('.*'))?\z>.match(str) or raise BadLogonString, "bad logon string: #{str.inspect}" new(* m.captures) end |
Instance Method Details
#inspect ⇒ Object
48 49 50 |
# File 'lib/teradata-cli/utils.rb', line 48 def inspect "\#<#{self.class} #{to_s}>" end |
#safe_string ⇒ Object
44 45 46 |
# File 'lib/teradata-cli/utils.rb', line 44 def safe_string "#{@tdpid ? @tdpid + '/' : ''}#{@user},****#{@account ? ',' + @account : ''}" end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/teradata-cli/utils.rb', line 40 def to_s "#{@tdpid ? @tdpid + '/' : ''}#{@user},#{@password}#{@account ? ',' + @account : ''}" end |