Method: OodCore::Job::Adapters::Torque::FFI::Attrl#to_h

Defined in:
lib/ood_core/job/adapters/torque/ffi.rb

#to_hHash

Convert to hash describing this linked list

Returns:

  • (Hash)

    hash describing linked list



228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 228

def to_h
  attrl = self
  hash = {}
  until attrl.to_ptr.null?
    n = attrl[:name].read_string
    v = attrl[:value].read_string
    r = attrl[:resource].null? ? nil : attrl[:resource].read_string
    r ? (hash[n.to_sym] ||= {} and hash[n.to_sym][r.to_sym] = v) : hash[n.to_sym] = v
    attrl = attrl[:next]
  end
  hash
end