class TORQUE::Qstat::EnanchedOpenStruct

DEPRECATED # FIELDS = %w(job_id job_name job_owner resources_used_cput resources_used_mem resources_used_vmem

           resources_used_walltime job_state substate queue server checkpoint ctime error_path exec_host
           exec_port hold_types join_path keep_files mail_points mail_users mtime output_path
           priority qtime rerunable resource_list session_id shell_path_list variable_list 
           euser egroup hashname queue_rank queue_type comment etime
           exit_status submit_args walltime_remaining start_time start_count fault_tolerant comp_time job_radix total_runtime
           submit_host nppcu)
Job = Struct.new(:job_id, :job_name, :job_owner, :resources_used_cput, :resources_used_mem, :resources_used_vmem,
       :resources_used_walltime, :job_state, :substate, :queue, :server, :checkpoint, :ctime, :error_path, :exec_host,
       :exec_port, :hold_types, :join_path, :keep_files, :mail_points, :mail_users, :mtime, :output_path,
       :priority, :qtime, :rerunable, :resource_list, :session_id,
       :shell_path_list, :variable_list, :euser, :egroup, :hashname, :queue_rank, :queue_type, :comment,
       :etime, :exit_status, :submit_args, :walltime_remaining, :start_time,
       :start_count, :fault_tolerant, :comp_time, :job_radix, :total_runtime, :submit_host, :nppcu) do

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/torque_rm/qstat.rb, line 25
def initialize(*args)
  super(*args)
  casting
  alias_case_insensitive_methods
end

Private Instance Methods

alias_case_insensitive_methods() click to toggle source
# File lib/torque_rm/qstat.rb, line 54
def alias_case_insensitive_methods
  @table.each_pair do |k,v| #adding methods
    unless k == k.downcase
      original=k.to_sym
      newer=k.downcase.to_sym
      class_eval do
        alias_method newer, original 
        alias_method "#{newer}=", "#{original}="
      end
    end
  end
end
casting() click to toggle source

Cast generic types from string to most near type selected by pattern matching

# File lib/torque_rm/qstat.rb, line 34
def casting
  @table.each_pair do |k,v| #converting
    if v =~ (/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/)
      hours,minutes,seconds = v.split(':')
      now = Time.now
      send "#{k}=", Time.diff(now, now-((hours.to_i/24)*(24*3600))-((hours.to_i%24)*3600)-(minutes.to_i*60)-(seconds.to_i)) #time_diff object
    elsif k.to_s =~ /time/ && v.is_a?(String) && v =~ (/^[0-9]+$/)
      send "#{k}=", Time.at(v.to_i).to_datetime
    elsif v =~ (/(true)$/i)
      send "#{k}=", true
    elsif v =~ (/(false)$/i)
      send "#{k}=", false
    elsif v =~ (/^[0-9]+$/)
      send "#{k}=", v.to_i
    elsif v.is_a? Hash
      send "#{k}=", EnanchedOpenStruct.new(v)
    end
  end #each pair
end