> Can I use ruby like my linux shell script(e.x. bash)?
Yes, you can. 

> For example, how to access environmental variables?
via ENV hash.