lib/hawatel_ps/linux/proc_table.rb
def search_by_condition(args)
          refresh
          attr = args[:attr]
          oper  = args[:oper]
          value = args[:value]
          process_list = Array.new
          @proc_table.each do |process|
            value = value.to_i if process[:"#{attr}"].is_a? Fixnum
            value = value.to_f if process[:"#{attr}"].is_a? Float
            if oper == '>'
              process_list << process if process[:"#{attr}"] > value if process[:"#{attr}"]
            elsif oper == '<'
              process_list << process if process[:"#{attr}"] < value if process[:"#{attr}"]
            elsif oper == '>='
              process_list << process if process[:"#{attr}"] >= value if process[:"#{attr}"]
            elsif oper == '<='
              process_list << process if process[:"#{attr}"] <= value if process[:"#{attr}"]
            elsif oper == '=='
              process_list << process if process[:"#{attr}"] == value if process[:"#{attr}"]
            elsif oper == '!='
              process_list << process if process[:"#{attr}"] != value if process[:"#{attr}"]
            end
          end
          return process_list
        end
# Return attributes of searched process based on specified condition
#
# @example
#   search_by_condition(:attrs => 'vmsize', :oper => '<', value => '10000')
#
# @param args[Hash] attributes for search condition
# @option :attr [String], name of process attribute (first expression for if)
# @option :oper [String], operatator, available options: >,<,>=,<=,==,!=
# @option :value [String], value comparable (second expression for if)
#
# @return [Array<ProcInfo>] array of ProcInfo objects
Return attributes of searched process based on specified condition
Return attributes of searched process based on specified condition
def search_by_condition(args)
          refresh
          attr = args[:attr]
          oper  = args[:oper]
          value = args[:value]
          process_list = Array.new
          @proc_table.each do |process|
            value = value.to_i if process[:"#{attr}"].is_a? Fixnum
            value = value.to_f if process[:"#{attr}"].is_a? Float
            if oper == '>'
              process_list << process if process[:"#{attr}"] > value if process[:"#{attr}"]
            elsif oper == '<'
              process_list << process if process[:"#{attr}"] < value if process[:"#{attr}"]
            elsif oper == '>='
              process_list << process if process[:"#{attr}"] >= value if process[:"#{attr}"]
            elsif oper == '<='
              process_list << process if process[:"#{attr}"] <= value if process[:"#{attr}"]
            elsif oper == '=='
              process_list << process if process[:"#{attr}"] == value if process[:"#{attr}"]
            elsif oper == '!='
              process_list << process if process[:"#{attr}"] != value if process[:"#{attr}"]
            end
          end
          return process_list
        end
def search_by_condition ( args ) refresh attr = args [ :attr ] oper = args [ :oper ] value = args [ :value ] process_list = Array . new @proc_table . each do | process | value = value . to_i if process [ :" #{ attr } " ] . is_a? Fixnum value = value . to_f if process [ :" #{ attr } " ] . is_a? Float if oper == '>' process_list << process if process [ :" #{ attr } " ] > value if process [ :" #{ attr } " ] elsif oper == '<' process_list << process if process [ :" #{ attr } " ] < value if process [ :" #{ attr } " ] elsif oper == '>=' process_list << process if process [ :" #{ attr } " ] >= value if process [ :" #{ attr } " ] elsif oper == '<=' process_list << process if process [ :" #{ attr } " ] <= value if process [ :" #{ attr } " ] elsif oper == '==' process_list << process if process [ :" #{ attr } " ] == value if process [ :" #{ attr } " ] elsif oper == '!=' process_list << process if process [ :" #{ attr } " ] != value if process [ :" #{ attr } " ] end end return process_list end
Return attributes of searched process based on specified condition
Return attributes of searched process based on specified condition
array of ProcInfo objects
array of ProcInfo objects
Array<ProcInfo>
args
attributes for search condition
attributes for search condition
:attr
, name of process attribute (first expression for if)
name of process attribute ( first expression for if )
:oper
None
:value
, value comparable (second expression for if)
value comparable ( second expression for if )
example
None