Class: VmInfo::State

Inherits:
Object
  • Object
show all
Defined in:
lib/archipel/api/vm/vm_info.rb

Constant Summary collapse

STARTED =
new 1, 'started'
STOPPED =
new 5, 'stopped'
@@index =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, name) ⇒ State

Returns a new instance of State.



10
11
12
13
# File 'lib/archipel/api/vm/vm_info.rb', line 10

def initialize value, name
  @value, @name = value, name
  @@index[value] = self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/archipel/api/vm/vm_info.rb', line 22

def method_missing method, *args
  if method[-1] == '?'
    method[0..-2] == name
  else
    super
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/archipel/api/vm/vm_info.rb', line 7

def name
  @name
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/archipel/api/vm/vm_info.rb', line 7

def value
  @value
end

Class Method Details

.from_int(value) ⇒ Object



34
35
36
# File 'lib/archipel/api/vm/vm_info.rb', line 34

def self.from_int value
  @@index[value]
end

Instance Method Details

#to_sObject



30
31
32
# File 'lib/archipel/api/vm/vm_info.rb', line 30

def to_s
  "VM state: #{name} (#{value})"
end