Idiomatic status check

Hi,

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
up:

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

What’s the preferred way?

2008/11/19 The O. [email protected]:

What’s the preferred way?

Why not just

def running?
/etc/init.d/postgresql-8.3 status.split[3] == “up”
end

or even

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

?

Kind regards

robert