To loop through an array and only print if eq "app.crash"

Ruby script to loop through an array and only print if eq “app.crash”
not getting results I want.

This ruby script take a command and puts into an array then removes the
first three elements of the array.
Trying the loop through the array and show only if it eq “app.crash”
but I not been able to do that.

Below is a sample of the output of the cammand.
[email protected]:~# cf events cust3-166-563
Getting events for app cust3-166-563 in org attac / space amecheapps as
admin…

time event actor
description
2015-07-29T19:39:35.00+0000 audit.app.update admin
state: STARTED
2015-07-29T19:17:29.00+0000 audit.app.update admin
state: STOPPED
2015-07-29T09:57:05.00+0000 app.crash cust3-166-563
index: 0, reason: CRASHED, exit_description: out of memory, exit_status:
255
2015-07-21T15:33:23.00+0000 audit.app.update admin
state: STARTED

#!/usr/bin/env ruby

$apps = cf events cust3-166-563.split(/$/).map(&:strip)
$apps.shift
$apps.delete_at(0)
$apps.delete_at(0)

for apps in $pword
puts “#{apps.include?(‘app.crash’)}, \n”
if #{apps.include?(‘app.crash’)} === “true”
puts “#{apps.include?(‘app.crash’)}, \n”
end

Tom Thomas wrote in post #1177239:

if #{apps.include?(‘app.crash’)} === “true”

should be
if apps.include?(‘app.crash’)

end

raubarede, Thanks for the help!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs