Class: VirtualBox::COM::AbstractEnum
- Inherits:
-
AbstractModel
- Object
- AbstractModel
- VirtualBox::COM::AbstractEnum
- Defined in:
- lib/virtualbox/com/abstracts.rb,
ext/virtualbox-com/4.2/vbox.c,
ext/virtualbox-com/4.1/vbox.c,
ext/virtualbox-com/vbox.c
Direct Known Subclasses
Model::AccessMode, Model::AdditionsFacilityClass, Model::AdditionsFacilityStatus, Model::AdditionsFacilityType, Model::AdditionsRunLevelType, Model::AdditionsUpdateFlag, Model::AudioControllerType, Model::AudioDriverType, Model::AuthType, Model::AutostopType, Model::BIOSBootMenuMode, Model::BandwidthGroupType, Model::CPUPropertyType, Model::ChipsetType, Model::CleanupMode, Model::ClipboardMode, Model::CloneMode, Model::CloneOptions, Model::CopyFileFlag, Model::DataFlags, Model::DataType, Model::DeviceActivity, Model::DeviceType, Model::DirectoryCreateFlag, Model::DirectoryOpenFlag, Model::DirectoryRemoveRecFlag, Model::DragAndDropAction, Model::DragAndDropMode, Model::ExecuteProcessFlag, Model::ExecuteProcessStatus, Model::FaultToleranceState, Model::FileSeekType, Model::FirmwareType, Model::FramebufferPixelFormat, Model::FsObjType, Model::GuestDirEntryType, Model::GuestMonitorChangedEventType, Model::HWVirtExPropertyType, Model::HostNetworkInterfaceMediumType, Model::HostNetworkInterfaceStatus, Model::HostNetworkInterfaceType, Model::ImportOptions, Model::KeyboardHIDType, Model::KeyboardHidType, Model::LockType, Model::MachineState, Model::MediumFormatCapabilities, Model::MediumState, Model::MediumType, Model::MediumVariant, Model::MouseButtonState, Model::NATAliasMode, Model::NATProtocol, Model::NetworkAdapterPromiscModePolicy, Model::NetworkAdapterType, Model::NetworkAttachmentType, Model::PathRenameFlag, Model::PointingHIDType, Model::PointingHidType, Model::PortMode, Model::ProcessCreateFlag, Model::ProcessInputFlag, Model::ProcessOutputFlag, Model::ProcessPriority, Model::ProcessStatus, Model::ProcessWaitForFlag, Model::ProcessWaitResult, Model::ProcessorFeature, Model::Scope, Model::SessionState, Model::SessionType, Model::SettingsVersion, Model::StorageBus, Model::StorageControllerType, Model::SymlinkReadFlag, Model::SymlinkType, Model::USBDeviceFilterAction, Model::USBDeviceState, Model::VBoxEventType, Model::VFSFileType, Model::VFSType, Model::VirtualSystemDescriptionType, Model::VirtualSystemDescriptionValueType
Class Method Summary collapse
-
.[](index) ⇒ Object
Returns the symbol/value association.
-
.each ⇒ Object
Iterate over the enum, yielding each item to a block.
-
.map(value = nil) ⇒ Object
Defines the mapping of int => symbol for the given Enum.
- .symbol(value) ⇒ Object
- .value(symbol) ⇒ Object
Methods inherited from AbstractModel
Class Method Details
.[](index) ⇒ Object
Returns the symbol/value association
34 35 36 37 38 39 |
# File 'lib/virtualbox/com/abstracts.rb', line 34 def self.[](index) case index when Symbol then @map[index] else @rmap[index] end end |
.each ⇒ Object
Iterate over the enum, yielding each item to a block.
27 28 29 30 31 |
# File 'lib/virtualbox/com/abstracts.rb', line 27 def self.each @map.each do |key, value| yield key end end |
.map(value = nil) ⇒ Object
Defines the mapping of int => symbol for the given Enum. The parameter to this can be an Array or Hash or anything which respond to ‘each` and yield a key/value pair. If a value appear more than once, only the first is kept If value is left nil, it will return the current mapping
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/virtualbox/com/abstracts.rb', line 13 def self.map(value = nil) if value m, r = {}, {} if Array === value then value.each_index {|i| m[value[i]] = i; r[i] = value[i] } else value.each {|k,v| m[k] = v; r[v] ||= k } end @map, @rmap = m.freeze, r.freeze end @map end |
.symbol(value) ⇒ Object
41 42 43 |
# File 'lib/virtualbox/com/abstracts.rb', line 41 def self.symbol(value) @rmap[value] end |
.value(symbol) ⇒ Object
45 46 47 |
# File 'lib/virtualbox/com/abstracts.rb', line 45 def self.value(symbol) @map[symbol] end |