1. Home
  2. Computing & Technology
  3. Ruby

Ruby: Most Popular Articles

These articles are the most popular over the last month.
Command-line Arguments
Use command-line arguments to pass parameters to your Ruby scripts from the command line.
The 'require' Method
The 'require' method is the reusable code mechanism in Ruby. It allows you to import other source files into your programs.
Comments
Use comments to annotate your Ruby code.
Distributed Programming
Distributed Programming with Ruby by Mark Bates is a broad look at all options available for distributed programming with Ruby. Though the book covers many libraries (those included with Ruby as well as via RubyGems), it still covers the underlaying technologies and gives valuable background information. In short, Distributed Programming with Ruby packs a powerful punch in its 250 or so pages. Anyone working with distributed programming in Ruby will want this book.
Environment Variables
Using environment variables in Ruby.
Parse Command Line Options
Ruby comes equipped with a powerful and flexible tool to parse command-line options, OptionParser. The class is an alternative to GetoptLong for analyzing command line options.
Installing Ruby
How to install the Ruby interpreter on Windows, Linux and OS X.
Starting the Blog
Part one of the Ruby on Rails blog tutorial focuses on creating a Rails project and scaffolding a basic blog post data structure.
Install Ruby on Linux
How to install Ruby on the Linux operating system.
The Twitter API
The Twitter API (Application Programming Interface) in Ruby on Rails is about as simple as you can get. Twitter is a RESTful Rails application.
Tk
Directions of how to install the Tk GUI and its Ruby bindings on Windows, Linux and Mac OS X.
Using the Command Line
Learn how to use the command line interface on Windows, Linux and OS X to run rb files and use the interactive Ruby program.
The logger Library
How to use the logger library to create and write to log files in Ruby.
What is Ruby?
What type of language is the Ruby programming language?
nokogiri
Up until now, Hpricot HTML parser for Ruby has been the fast an easy standard. The Nokogiri Ruby gem can parse not only HTML, but also works with XML, CSS and XPath selectors.
Install Ruby on Windows
How to install the Ruby interpreter on the Windows operating system.
Install Ruby on OS X
How to install Ruby on Apple OS X
Installing Rubygame on Windows
A visual tutorial with screenshots showing how to install the Rubygame library on Windows, including installing all needed DLL files.
Parsing Twitter XML
Learn how to parse the Twitter API's XML easily using Hpricot.
Getting Started With Ruby
How to use the command line interface on Windows, Linux and OS X to run Ruby scripts and use the interactive Ruby program.
Ruby Gems
Learn to search the Ruby Gems repository to find gems to add and install to your library.
OptionParser
Using OptionParser to parse command line options is a preferable alternative to GetoptLong or looking through ARGV manually. But how do you use it?
Adding RESTful Authentication
Part three of the Ruby on Rails blog tutorial uses the RESTful authentication plugin to make sure only authorized users can make posts to your blog.
Learn to Use Regex in Ruby
What is a regular expression and how do you use them in Ruby?
String Substitution in Ruby
Splitting a string is only one way to manipulate string data. You can also make substitutions to replace one part of a string with another string. For instance, in an example string "foo,bar,baz", replacing "foo" with "boo" in "foo,bar,baz" would yield "boo,bar,baz". You can do this and many more things using the sub and gsub method in the String class.
Builder RubyGem
The Builder library is a Ruby Gem that uses a meta-language to generate HTML, XML or CSS markup.
An Introduction to Shoes
This tutorial is a introductory look at the Shoes GUI toolkit for Ruby. You'll find it is easy to learn, making it a good option for beginning programmers to make Shoes online applications.
Arrays
This article explains and teaches how to use a arrays as a way to store multiple variables in one data structure.
Strings
Using and manipulating strings and substrings in Ruby.
Using the 'split' Method
String manipulation using the split method in Ruby. Split strings into a list of substrings.
A Benchmarking Experiment
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.
While, Until, Each and Time
Loops, including while and include loops, are one of the most commonly used constructs in computer programs.
How to Use the Gem Command
The gem command is one of the most used Ruby-related commands. This article shows 25 Gem Commands and their functions.
Riding Shotgun with Sinatra
Now that you can write controller logic and views and Haml, you can start putting together some more complex application. There's one very annoying thing though: Sinatra does not reload its code whenever you make a change. If you make a change, you have to stop and restart the server. This is just an extra step and generally an annoyance. This where shotgun comes in.
Hashes
This article explains and teaches how to use a associative arrays (hashes) as a way to store multiple variables in one data structure.
The Twitter RubyGem
Using the Twitter RubyGem, making API requests to Twitter is even easier than using the twitter method.
Comments on the Ruby Blog
Part four of the Ruby on Rails blog tutorial shows you how to create a comments table to allow users to comment on your blog posts.
Spotlight on Gems: TMail
The TMail gem provides an interface for manipulating and parsing email messages.
Using Haml with Sinatra
How to use Haml to create Sinatra views and layouts.
DataMapper Introduction
DataMapper is a "Object/Relational Mapper" or ORM. In other words, it maps Ruby objects to database records that makes with objects from a database a snap.
Send Email with Ruby
How to send email with Ruby on Rails using SMTP.
Running the Ruby Profiler
Running the Ruby profiler to determine which methods are most expensive and which need to be optimized.
Ruby's Bignum Library
Computers are quite good at math or, more precisely, at arithmetic. In fact, technically, that's all a computer can do. However, the numbers computers typically work with are quite limited. On a typical computer, an integer number is represented by a 32-bit binary number. A 32-bit integer can only represent the numbers from about negative 2 billion to positive 2 billion.
5 Must Know Features of Ruby
If you're going to program in the Ruby language, there are some basic features you absolutely must know. Here are the Top 5.
Mixin Modules
Mixins are one of Ruby's defining features, but often one of the most difficult to understand for those new to Ruby. They're not difficult to understand, but they're not something most programmers have encountered before as most languages don't have mixins.
Spotlight on Gems: Prawn
Prawn is a pure-Ruby library for generating PDF files. From your Ruby code, you'll be able to compose PDF files with any content and of any size. This is not only ideal for generating reports, but also for formatting documentation and providing a portable format for your program's output.
Using rails.vim
Editing Rails projects in Vim effectively.
Creating the "Blog Look"
Part two of the Ruby on Rails blog tutorial focuses on using the Yahoo! UI library to help make your blog look like a blog.
Special Characters
Aside from the basic regular expression operators such as groupings and quantifiers, there are some other special characters and escape sequences (backslash followed by a character) that can help you out when you're working with Ruby.
Interact with SSH in Ruby
Net::SSH is a way for Ruby to interact with SSH (Secure Shell) protocol. It relies on the OpenSSL library for encryption.
Create Menus in WxRuby
Menus are relatively easy to create and use in wxRuby,you only need to create a Wx::MenuBar object to hold all of the menus, and a number of Wx::Menu objects.
Package Manager
A package manager is software on a Linux system that manages the other software installed on the system.
Distributed Ruby
Distributed Ruby, or DRb, is a library that allows you to communicate with remote Ruby objects and programs, using TCP/IP network protocols.
Hello, Sinatra!
How to get started in Sinatra, including how to use actions, parameters, ERB and views.
10 Ways to Learn Ruby for Free
Sometimes the old adage rings true: the best things in life are free. If you've wanted to learn a little Ruby, but haven't been able to fit a programming course into your budget, don't worry. There are a number of places on the Web to begin your learning, without sacrificing money or quality.
Ruby vs. Python
How do Ruby and Python compare in terms of features, form and function?
Installing wxRuby
wxRuby, a GUI toolkit for Ruby which interfaces with wxWidgets, can be installed on Ubuntu Linux with relative ease.
Hello WxRuby World
Want to learn how to use WxRuby? There's no better way to get started than to write a "Hello World" program.
Update from an RSS Feed
This Ruby script to update Twitter from an RSS feed is what's often referred to as a "mashup." Mashups interface one protocol to another, or one website to another. This mashup takes information from an RSS feed and posts it as updates to Twitter.
Ruby vs. Java
What features do Ruby and the Java programming language share? How are they alike and how are they different?
Blocks
How to use blocks in Ruby.
Defining Cloud Computing
What is cloud computing? Interviews with industry experts help us define cloud computing, software as service, platform as service and more.
Installing NetBeans
The NetBeans IDE created by Sun Microsystems is often associated with Java development. However, in the past few years, Sun has slowly been adding support for more languages to NetBeans. Ruby (and more specifically, JRuby) is one of those languages.
Database-driven Apps
This article will create a rolodex application that can be used to keep track of contact information. The total line count is about 130 lines, split about half and half with code and views.
Unit Tests
Learn the basics of writing and running unit tests for test driven development in Rails.
Aliasing
Aliasing is a powerful Ruby feature that allows more than one method to be referred to by multiple names. This can be used to give a programmer more expressive options or to create copies of a method, allowing you to change the behavior of a class.
Regex: Grouping
The grouping operators, including the parentheses operator, are some of the most powerful and frequently used operators in the Ruby regex syntax.
Variables
What are Variables and how to use Variables in Ruby.
Exception Classes
Knowing how to make quick exceptions to catch and tell the difference between several conditions is a Ruby best practice you can't afford not to know.
Installing Gems from Git
How to install gems from git repositories.
Ruby Version Manager
Ruby Version Manager is a new gem that allows you to easily install and switch between Ruby interpreters. This includes switching between different versions of the official Ruby interpreter, including different patch levels, as well as switching to different Ruby interpreters altogether.
Twittering in Ruby
Twitter provides programmers with an excellent API, which is why so many Twitter interfaces exist for tweeting, following updates, following friends and thread-sorting. Writing Twitter clients in Ruby is a breeze!
Ruby vs. PHP
What are the similarities and dissimilarities between Ruby and PHP?
Modules
In any programming language, you need some way to prevent naming clashes. This is especially true when you're using at least one third party library, where you have no control over the naming scheme. In the past, naming conventions would be used. It's not uncommon to see C programs with names like mylibrary_some_function. However, Ruby has a more powerful solution: modules.
Cloud Computing and Ruby
Why are cloud computing and Ruby on Rails a good match? Let's hear what Hampton Catlin, author of HAML and Wikipedia's head Ruby/mobile architect has to say!
Ruby vs. Perl
How do Ruby and Perl compare in function and form?
The Main Loop
The main loop is the heartbeat of any game, and is the first thing you need to learn to start making your own games.
Email Addresses
Using regular expression to tell if an email address is valid or not.
Exceptions
Exceptions are used to handle things the unexpected things that might go wrong with your Ruby code. This article addresses what Exceptions are and how they can be used.
Using Buttons in Shoes
In a Shoes application, the button is one of the simplest elements. This tutorial will teach you how to make the most of the your GUI toolkit in Ruby.
Shoes' 5 Dialog Methods
We've all had to respond to that ubiquitous question: Are You Sure You Want to Exit? Ever wondered what was behind creating them? Shoes gives you 5 different dialog methods to choose from.
A Practical Twitter Script
Since the Twitter API makes it easy to do anything you can do on the website, writing a Ruby script to automatically follow followers is very simple.
Using Variables
Learn how to use variables in Ruby, assign them information using the assignment operator and pass to a variable using the "puts" function.
Input and Output
Input and output methods are often overlooked by many Ruby programmers. How often have you used the <b>gets</b> and <b>puts</b> methods without giving them a second glance? Learn all the features of these methods to better put them to use in your code.
4Ways
A comparison of Ruby to other programming languages, including Perl, Java, Python and PHP.
Vim
A review of the Vim text editor for writing Ruby code.
GeoIP
Using GeoIP databases to correlate IP addresses and physical locations using the GeoIP gem.
Syntax
The syntax of a language is the grammatical rules a program must follow in order to be understood by the interpreter or compiler.
WxWidgets
WxWidgets is a C++ GUI toolkit that can be used to write GUI (graphical user interface)applications. And WxRuby? Well, it's a Ruby binding and wrapper for the WxWidgets C++ classes.
External Return Value
Ruby makes it easy to run external programs and capture their output. Using the built-in "backtick" operator is as easy as running these programs from the command line. However, it's not obvious how to capture the return value of these programs.
Installing Ruby on Windows
A visual walkthrough on installing Ruby on Windows.
Loading and Displaying Sprites
Now that you know how to load and display a background image in Rubygame, it's time to move onto other graphics, like sprites. A sprite is a smaller graphic displayed on the screen, usually representing the part of the game like the player's ship in Space Invaders or Pac-man in any of the Pac-man games. Backgrounds usually remain static, while sprites can move around and be animated.
Named Regexp Groups
Ruby 1.9 introduces the concept of a named capture group. These named groups can be defined at the beginning of a regexp statement using a trick that tells for the regexp engine to look for exactly 0 instances of the group. Later, the group can be recalled using the \g element, followed by the name of the group. You can think of named capture groups as subroutines inside of a regular expression.
Making Nameless Methods in Rub
Among the new features in release of Ruby 1.9.1 is the Lambda operator, a shortcut used to make nameless methods. Learn how to use this feature introduced in Ruby 1.9.1.
YARV
YARV takes a vastly different approach to the problem of running Ruby programs. After the program is parsed and the syntax tree created, program for a virtual machine is created.
NetBeans Tour
When switching to a new IDE, program or environment, there's always an awkward phase during which you just don't know where to find anything. I'd been using the command prompt to run Rails commands for quite a while. However, you just can't do that with Netbeans.
Displaying Images With Shoes
Displaying images using the Shoes GUI toolkit is as simple as using the image method. This tutorial walks you through adding images in Shoes.
Test Suites
Grouping your test cases into test suites.
Events
Any element can be assigned a "click block," a block of code to run when the element is clicked. If the element is clicked, the click block will run. Learn how to use click blocks, event callbacks and animation in Shoes.
Sinatra URL Matching
How do do various types of URL matching in Sinatra.
Question Mark Operator
Among the new features in release of Ruby 1.9.1 is what the question mark operator will return. Learn what happens now in Ruby 1.9.1.
Following Updates on Twitter
Learn how to follow Twitter updates using Twitter's openly-provided Ruby API.
Regular Expression Options
Using options to change the behavior of regular expressions.
Regular Expression Syntax
The basic syntactical elements of regular expressions in Ruby.
Try Ruby!
You can learn Ruby for free with this online tutorial, Try Ruby! A quick profile of why the lucky stiff's in-your-browser Ruby lessons for beginners.
jobsites
Looking for a job as a Ruby or Rails programmer? These websites are a great place to start.
Loading and Displaying Images
Loading images from files and displaying them om the screen is the one of the most basic things you can do in game programming. Luckily, Rubygame makes this really simple.
Option Hashes
Using hashes to simulate optional named parameters in methods.
Debugging Ruby
Debugging Ruby programs using the Ruby debugger.
protect_from_forgery
A feature in Rails that protects against Cross-Site Request Forgery (CSRF) attacks.
Hello World Program
A Hello World program is a small program that simply prints something (usually "Hello world!") to the screen.
Data Structure
A data structure is a scheme for storing related data in memory so it can be retrieved in the least amount of time.
Using the Jabber Protocol
Be notified of Twitter updates by IM, using this Ruby script. It's a pain to switch to a Web browser every you want to check your Twitter account. This script solves that by sending you an instant message (IM) using the Jabber protocol when there's something new to see on Twitter.
3 Ruby Scripts for Twitter
Exploring and knowing the Twitter API is fine, but what do you do from there? Here are 3 practical scripts to help you follow followers on Twitter, update your Twitter account via an RSS feed and to be notified of your friend's new Tweets as they come in.
Wirble
The Wirble Gem provides a number of practical features for the IRB, including colorization, which makes reading output much easier.
Simple RSS
The Simple-RSS RubyGem provides a simplified interface for reading RSS and Atom documents.
TDD
You may have heard of Test-Driven Development, but what does it really mean? Learn the reasons for using TDD and the features of it.
Associative Array
A named collection of key/value pairs.
practicalplugins
A review of the book Practical Rails Plugins written by Nick Plante and David Berube, published by Apress.
Top 5 New Features in Ruby 1.9
The 5 most interesting or useful features in the new Ruby 1.9.1 release.
Installing Ruby 1.9.1 on Linux
Install Ruby 1.9.1 on your Linux machine alongside your current Ruby 1.8.x distribution to upgrade it. You'll have to compile the code from source, as shown in this tutorial.
Ruby - QuickTips
An index of QuickTips for the Ruby guide site.
Attack Example #1
Concerned about security with your Ruby code? Check out this analysis of an CSRF attack (without XSS).
Implementing a Spinner
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.
XML Parser
A program that reads an XML stream.
Tk Widgets
How to use some of the most basic Tk widgets.
Rounding Down
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?
Transfer Files with Net::SCP
SSH is not just for [link url=/od/ssh/a/runprogramsnetssh.htm]running commands[/link], it's a general conduit for encrypted communications between two hosts. One common use for SSH is to transfer files using the SCP protocol over SSH. You can use SCP in your Ruby programs with the Net::SCP library, which is a supplement to Net::SSH.
What is Sinatra?
Sinatra is a web framework. Simply put, it's a library that allows you to write web applications with a minimum of red tape.
Edit Boxes
A quick tutorial taking you through using edit_line and edit_box elements in Shoes to provide text editing.
Fibers
Fibers are lighter than threads. A fiber is a bit like a method, but instead of being run in its entirety when called, a Fiber will run until it yields a value. At this point, it will save its internal state and suspend itself and control will return to the caller.
Ruby Regexen
Regular Expressions provide a way search for patterns, strings or specific characters in your code. Learn how to start creating regular expressions in Ruby.
Beginning Ruby
A review of the book Beginning Ruby: From Novice to Professional by Peter Cooper from Apress.
What's New in Rails 2.2?
The release of Ruby on Rails 2.2 bring a new set of features to the table. While release 2.2 is only an incremental release and there are no major architectural changes, there are still some important thing you should know about.
What is Ruby on Rails?
What is the Ruby on Rails web framework?
Using Open Classes
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
Cloud Computing
What is cloud computing? We asked Dave Vandervort of Xerox Innovation Group to help us answer that question and more.
IMG Tag
The IMG tag places an image in an HTML document.
Input/Output
Input/Output (commonly referred to as i/o or IO) is the data being input into the program (from file, network or keyboard) and the output generated by the program (written to file, network or screen).
Regular Expression
Regular expression is a specialized computer language for matching strings of text.
Graphical User Interface
A graphical user interface (or GUI) is an interface to a program built with images, words and symbols.
Blocks in Ruby 1.9.1
The release of Ruby 1.9.1 brings new features to be learned,among them are the changes in block variable scope. Learn the new syntax for block variable scope introduced in Ruby 1.9.1.
Newline
A character or sequence of characters used to signify to a terminal or typesetting program that a line has ended and a new line is beginning.
Spotlight on RubyGems: Cheat
Using the RubyGem 'cheat' for access to wiki-like cheat sheets.
Handling Input
Now that we have the player sprite loaded and displayed, and the player itself is a class, it's time to make it move. There are two ways to handle input: handling the events or getting the keyboard state. In this article, only events will be discussed.
Sketches
Sketches is a really cool gem that helps you test out code in IRB. Without a tool like Sketches to test out some code in IRB you can either type it directly into IRB, or save it in a file and load it with IRB. This is what Sketches solves, it will automatically reload a Ruby script (referred to as a "Sketch") every time you make changes to it. This allows you the comfort of editing in your favorite editor and having easy access to the code in IRB.
Ruby on Rails
Ruby on Rails is a Model-View-Controller framework for web applications written in Ruby.
Spotlight on Gems: Trollop
In a previous article we discussed how to parse command-line options with Ruby's default OptionParser class. While this does work quite well, it's quite verbose. Trollop is a great library that solves these problems.
Conditionals
How to use conditional statements in Ruby
Named Character Classes
A listing of the named character classes available to you in regular expressions in Ruby.
Explore Ruby
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Ruby

©2009 About.com, a part of The New York Times Company.

All rights reserved.