Class: TeradataCli::LogonString

Inherits:
Object
  • Object
show all
Defined in:
lib/teradata-cli/utils.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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,  = nil)
  @tdpid = tdpid
  @user = user
  @password = password
  @account = 
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



38
39
40
# File 'lib/teradata-cli/utils.rb', line 38

def 
  @account
end

#passwordObject (readonly)

Returns the value of attribute password.



37
38
39
# File 'lib/teradata-cli/utils.rb', line 37

def password
  @password
end

#tdpidObject (readonly)

Returns the value of attribute tdpid.



35
36
37
# File 'lib/teradata-cli/utils.rb', line 35

def tdpid
  @tdpid
end

#userObject (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

#inspectObject



48
49
50
# File 'lib/teradata-cli/utils.rb', line 48

def inspect
  "\#<#{self.class} #{to_s}>"
end

#safe_stringObject



44
45
46
# File 'lib/teradata-cli/utils.rb', line 44

def safe_string
  "#{@tdpid ? @tdpid + '/' : ''}#{@user},****#{@account ? ',' + @account : ''}"
end

#to_sObject



40
41
42
# File 'lib/teradata-cli/utils.rb', line 40

def to_s
  "#{@tdpid ? @tdpid + '/' : ''}#{@user},#{@password}#{@account ? ',' + @account : ''}"
end