Class: HP::Cloud::BaseHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/hpcloud/base_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, foggy = nil) ⇒ BaseHelper

Returns a new instance of BaseHelper.



27
28
29
30
31
# File 'lib/hpcloud/base_helper.rb', line 27

def initialize(connection, foggy = nil)
  @connection = connection
  @cstatus = CliStatus.new
  @fog = foggy
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



25
26
27
# File 'lib/hpcloud/base_helper.rb', line 25

def connection
  @connection
end

#cstatusObject

Returns the value of attribute cstatus.



25
26
27
# File 'lib/hpcloud/base_helper.rb', line 25

def cstatus
  @cstatus
end

#fogObject

Returns the value of attribute fog.



25
26
27
# File 'lib/hpcloud/base_helper.rb', line 25

def fog
  @fog
end

Instance Method Details

#destroyObject



51
52
53
# File 'lib/hpcloud/base_helper.rb', line 51

def destroy
  @fog.destroy unless @fog.nil?
end

#is_valid?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/hpcloud/base_helper.rb', line 47

def is_valid?
  return @cstatus.is_success?
end

#set_error(noo, status = :general_error) ⇒ Object



40
41
42
43
44
45
# File 'lib/hpcloud/base_helper.rb', line 40

def set_error(noo, status = :general_error)
  unless noo.is_a?(CliStatus)
    noo = CliStatus.new(noo, status)
  end
  @cstatus.set(noo)
end

#to_hashObject



33
34
35
36
37
38
# File 'lib/hpcloud/base_helper.rb', line 33

def to_hash
  return nil unless is_valid?
  hash = {}
  instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
  hash
end