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

#refresh, #reload, resource_name, #url

Methods included from SpecifiedAttributes

#get_api_attribute, included

Constructor Details

#initialize(attrs, vm, env) ⇒ Credentials

Returns a new instance of Credentials.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-skytap/api/credentials.rb', line 13

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.



9
10
11
# File 'lib/vagrant-skytap/api/credentials.rb', line 9

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



9
10
11
# File 'lib/vagrant-skytap/api/credentials.rb', line 9

def username
  @username
end

#vmObject (readonly)

Returns the value of attribute vm.



8
9
10
# File 'lib/vagrant-skytap/api/credentials.rb', line 8

def vm
  @vm
end

Instance Method Details

#recognized?Boolean

Are the credentials in a form that we recognize?

Returns:

  • (Boolean)


27
28
29
# File 'lib/vagrant-skytap/api/credentials.rb', line 27

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

#to_sObject



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

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