Ruby Snippets


Contents:

This is a simple file of snippets to show useful ruby tidbits:

Print All But Last

This prints all but the last line of an input stream. It was used by someone who's antiquated printing software added a ^L to the very end of the file.

  $stdin.each { |line|
    puts line unless $stdin.eof
  }

Mac OS X Upgrade

This will upgrade you to version 1.8.2 (the current latest, please check and make sure this is still current if you use this). It requires that you have the free apple developer tools installed. Chances are, you already do if you are interested in using ruby.

  cd /usr/bin
  sudo mv ruby ruby16
  sudo mv irb irb16
  cd ~/Desktop
  curl ftp.ruby-lang.org /pub /ruby /ruby-1.8.2.tar.gz > ruby-1.8.2.tar.gz
  tar zxf !$
  cd ruby-1.8.2
  ./configure
  make && sudo make install install-doc