Class: VagrantPlugins::Skytap::API::Credentials

Inherits:
Resource show all
Defined in:
lib/vagrant-skytap/api/credentials.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#attrs, #env

Instance Method Summary collapse

Methods inherited from Resource

#delete, #refresh, #reload, rest_name, short_name, #update, #url

Methods included from SpecifiedAttributes

#get_api_attribute, included

Constructor Details

#initialize(attrs, vm, env) ⇒ Credentials

Returns a new instance of Credentials.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vagrant-skytap/api/credentials.rb', line 35

def initialize(attrs, vm, env)
  super
  @vm = vm

  # Set username and password if we recognize them in the form
  # "uname / pw."
  uname, pw = text.split('/', 2).collect(&:strip)
  if uname && pw
    @username = uname
    @password = pw
  end
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



31
32
33
# File 'lib/vagrant-skytap/api/credentials.rb', line 31

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



31
32
33
# File 'lib/vagrant-skytap/api/credentials.rb', line 31

def username
  @username
end

#vmObject (readonly)

Returns the value of attribute vm.



30
31
32
# File 'lib/vagrant-skytap/api/credentials.rb', line 30

def vm
  @vm
end

Instance Method Details

#recognized?Boolean

Are the credentials in a form that we recognize?

Returns:

  • (Boolean)


49
50
51
# File 'lib/vagrant-skytap/api/credentials.rb', line 49

def recognized?
  !!(@username && @password)
end

#to_sObject



53
54
55
56
57
58
59
# File 'lib/vagrant-skytap/api/credentials.rb', line 53

def to_s
  if recognized?
    "#{username} / #{password}"
  else
    text
  end
end