Forum: Ruby Idiomatic status check

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sven S. (Guest)
on 2008-11-19 14:12

how would idiomatic Ruby look like when it comes to status checks of
processes? Here's a short method which checks if a PostgreSQL cluster is

  def running?
    output = `/etc/init.d/postgresql-8.3 status`.split
    output[3] == "up" ? true : false

What's the preferred way?
Robert K. (Guest)
on 2008-11-19 16:35
(Received via mailing list)
2008/11/19 The O. <removed_email_address@domain.invalid>:
> What's the preferred way?

Why not just

def running?
  `/etc/init.d/postgresql-8.3 status`.split[3] == "up"

or even

def running?
  /\bup\b/ =~ `/etc/init.d/postgresql-8.3 status`


Kind regards

This topic is locked and can not be replied to.