My ruby skillz are not good enough to write this one-liner in ruby, so I opted for shell / grep / sed.