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?

···

--
Posted via http://www.ruby-forum.com/.

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

···

2008/11/19 The One <kioo@intothespirit.com>:

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?

--
remember.guy do |as, often| as.you_can - without end