bashのシェバン(shebang)の応用ですね。
同様にRubyも可能です。

#! /usr/bin/env ruby