Class: OodCore::Job::Adapters::Torque::FFI::Attropl

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/ood_core/job/adapters/torque/ffi.rb

Overview

Struct for Attribute Operation C-linked list

Class Method Summary collapse

Class Method Details

.from_list(list) ⇒ Attropl

Convert to C-linked list of structs from list of hashes

Parameters:

  • list (Array<#to_h>)

    list of hashes describing attribute

Returns:

  • (Attropl)

    generated attribute operation c-linked list object



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/ood_core/job/adapters/torque/ffi.rb', line 253

def self.from_list(list)
  list = list.map(&:to_h)
  attropl = nil
  prev = Attropl.new(::FFI::Pointer::NULL)
  list.each do |attrib|
    attropl = Attropl.new
    attropl[:name]     = ::FFI::MemoryPointer.from_string attrib[:name].to_s
    attropl[:value]    = ::FFI::MemoryPointer.from_string attrib[:value].to_s
    attropl[:resource] = ::FFI::MemoryPointer.from_string attrib[:resource].to_s
    attropl[:op]       = (attrib[:op] || :eq).to_sym
    attropl[:next]     = prev
    prev = attropl
  end
  attropl
end