require 'osx/cocoa'
module OSXApps
class Base
def self.all
OSX::NSWorkspace.sharedWorkspace.launchedApplications.map do |app|
{:name => app.allValues[5].to_s, :pid => app.allValues[1].to_i}
end
end
def self.find(name)
all.find { |app| app[:name].match(name) }
end
end
end
if $0 == __FILE__
puts OSXApps.find('Terminal').inspect
end