1. Computing
Filed In:
  1. Tutorials

Ruby Programming FAQs

The FAQ section answers your Ruby coding questions with detailed task analysis and code examples.

How Can I Use a Spinner Method in Ruby?
A spinner method provides the user with visual feedback that something is happening in the background. For Ruby programs that require long wait times, a spinner can be a good addition.

How Can I Rotate an Array?
How to rotate an array, so elements at the beginning of the list are added to the end of the list.

How Can I Rotate an Array in Ruby?
Rotating an array is not something the default Ruby library includes. However, it is quite easy and by using Ruby's open classes, you can add it to the Array class yourself

How do I round a float down if it's close to a whole number?
Is there a nice way to get the floating-point value of a number if it's floating-point, but the integer value if it's just X.0?

How Can I Benchmark Code in Ruby?
Benchmarking measures the time it takes to execute code and compares it to other code that accomplishes the same task. This is useful to see which is faster, and gives you the opportunity to use the faster code in your program.

Couldn't find Page without an ID
Problem: You've encountered the error message Couldn't find Page without an ID while trying to run find on an ActiveRecord class.

undefined method `to_sym' for nil:NilClass
Problem: Seemlingly at random, you've encountered the error undefined method `to_sym' for nil:NilClass, or a similar error message for any method name other than to_sym.

extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
Problem: You're trying to install a gem and you encounter an error reading no such file to load -- mkmf. This doesn't always occur, only when you're trying to install gems with native C code that must be compiled.

NameError: uninitialized constant Object::Something
Problem: You encounter an error reading NameError: uninitialized constant Something or NameError: uninitialized constant Object::Something (with...

NameError: undefined local variable or method `a' for #
Problem: You encounter an error reading NameError: undefined local variable or method `a' for # or NameError: undefined local variable or method...

Discuss in my forum

©2013 About.com. All rights reserved.