class PBS::Torque::Attropl

Struct for Attribute Operation C-linked list

Public Class Methods

from_list(list) click to toggle source

Convert to C-linked list of structs from list of hashes @param list [Array<#to_h>] list of hashes describing attribute @return [Attropl] generated attribute operation c-linked list object

# File lib/pbs/torque.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