class Procps::Column
Creates a column object with a typecasting for ps results.
Attributes
header[R]
to_s[R]
Public Class Methods
new(header, cast = nil, &cast_block)
click to toggle source
# File lib/procps/column.rb, line 7 def initialize(header, cast = nil, &cast_block) @cast = block_given? ? cast_block : cast raise ArgumentError, "a value of the :cast option must respond to a #call method or be nil" unless @cast.nil? || @cast.respond_to?(:call) @header = header.to_s.freeze freeze end
Public Instance Methods
call(value)
click to toggle source
Typecasts a raw value
# File lib/procps/column.rb, line 15 def call(value) @cast.nil? ? value : @cast.call(value) rescue => e warn e value end