From c4e5638fddf5a8651a28e05a9a89ee2bcad8b361 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 15 Sep 2007 15:54:02 +0000 Subject: [PATCH] add who example --- bindings/ruby/examples/who.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 bindings/ruby/examples/who.rb diff --git a/bindings/ruby/examples/who.rb b/bindings/ruby/examples/who.rb new file mode 100644 index 00000000..ab29574b --- /dev/null +++ b/bindings/ruby/examples/who.rb @@ -0,0 +1,13 @@ +require 'rbsigar' + +def format_time(who) + return Time.at(who.time).strftime("%b %e %H:%M") +end + +sigar = Sigar.new + +whos = sigar.who_list + +whos.each do |who| + puts who.user + "\t" + who.device + "\t" + format_time(who) + who.host +end