Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Saturday, August 11, 2012

Ruby Rails: switches

Rails new:
-T #do not generate a test Directory; do this to replace test with Rspec also need to install Rspec $rails generate rspec:install

Ruby programming !sort


I was searching for a quick way to sort objects in Ruby and I found this ingenious method online.
deviceArray.sort! {|a,b| a.getName.downcase <=> b.getName.downcase}

notes
deviceArray : an array of objects of type device
downcase : only needed if sorting alpa numerically or can use upcase