Class: PBS::Torque::Attrl
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- PBS::Torque::Attrl
- Defined in:
- lib/pbs/torque.rb
Overview
Struct for Attribute C-linked list
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_list(list) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/pbs/torque.rb', line 83 def self.from_list(list) attrl = nil prev = Attrl.new(FFI::Pointer::NULL) list.each do |key| attrl = Attrl.new attrl[:name] = FFI::MemoryPointer.from_string(key.to_s) attrl[:resource] = FFI::Pointer::NULL attrl[:value] = FFI::Pointer::NULL attrl[:op] = 0 attrl[:next] = prev prev = attrl end attrl end |
Instance Method Details
#to_hash ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/pbs/torque.rb', line 98 def to_hash hash = Hash.new{ |h,k| h[k] = Hash.new() } attrl = self until attrl.to_ptr.null? name = attrl[:name].read_string.to_sym value = attrl[:value].read_string resource = nil resource = attrl[:resource].read_string.to_sym unless attrl[:resource].null? if resource.nil? hash[name] = value else hash[name][resource] = value end attrl = attrl[:next] end hash end |