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.
Environment Variables
Using environment variables in Ruby.
Comments
Use comments to annotate your Ruby code.
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.
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.
Install Ruby on Windows
How to install the Ruby interpreter on the Windows operating system.
Install Ruby on Linux
How to install Ruby on the Linux operating system.
Parsing Twitter XML
Learn how to parse the Twitter API's XML easily using Hpricot.
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.
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?
Learn to Use Regex in Ruby
What is a regular expression and how do you use them in Ruby?
Installing Ruby
How to install the Ruby interpreter on Windows, Linux and 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.
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.
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.
Starting the Blog
Generating a Rails project from which to build an application.
Strings
Using and manipulating strings and substrings in Ruby.
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.
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.
What is Ruby?
What type of language is the Ruby programming language?
Install Ruby on OS X
How to install Ruby on Apple OS X
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.
Send Email with Ruby
How to send email with Ruby on Rails using SMTP.
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.
Arrays
This article explains and teaches how to use a arrays as a way to store multiple variables in one data structure.
Using the 'split' Method
String manipulation using the split method in Ruby. Split strings into a list of substrings.
The logger Library
How to use the logger library to create and write to log files in Ruby.
While, Until, Each and Time
Loops, including while and include loops, are one of the most commonly used constructs in computer programs.
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.
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.
Checking Your Email with Ruby
How to check POP3 email accounts in Ruby.
Ruby Gems
Learn to search the Ruby Gems repository to find gems to add and install to your library.
Installing Gems from Git
How to install gems from git repositories.
Hashes
This article explains and teaches how to use a associative arrays (hashes) as a way to store multiple variables in one data structure.
Spotlight on Gems: TMail
The TMail gem provides an interface for manipulating and parsing email messages.
Tk
Directions of how to install the Tk GUI and its Ruby bindings on Windows, Linux and Mac OS X.
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.
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.
Blocks
How to use blocks in Ruby.
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.
Running the Ruby Profiler
Running the Ruby profiler to determine which methods are most expensive and which need to be optimized.
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.
Builder RubyGem
The Builder library is a Ruby Gem that uses a meta-language to generate HTML, XML or CSS markup.
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!
Hello, Sinatra!
How to get started in Sinatra, including how to use actions, parameters, ERB and views.
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.
Syntax
The syntax of a language is the grammatical rules a program must follow in order to be understood by the interpreter or compiler.
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.
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.
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.
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!
Defining Cloud Computing
What is cloud computing? Interviews with industry experts help us define cloud computing, software as service, platform as service and more.
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.
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.
Variables
What are Variables and how to use Variables in Ruby.
Using rails.vim
Editing Rails projects in Vim effectively.
Using Haml with Sinatra
How to use Haml to create Sinatra views and layouts.
Lookahead and Back-references
Using lookahead and back-references to refer to other parts of the regular expression text.
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.
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.
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.
protect_from_forgery
A feature in Rails that protects against Cross-Site Request Forgery (CSRF) attacks.
Email Addresses
Using regular expression to tell if an email address is valid or not.
4Ways
A comparison of Ruby to other programming languages, including Perl, Java, Python and PHP.
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.
GeoIP
Using GeoIP databases to correlate IP addresses and physical locations using the GeoIP gem.
exec and exec!
Running programs with Net::SSH is simple enough. The Session object gives you two convenient methods with which to accomplish this task.
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.
The Twitter RubyGem
Using the Twitter RubyGem, making API requests to Twitter is even easier than using the twitter method.
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
Debugging Ruby
Debugging Ruby programs using the Ruby debugger.
Ruby vs. Perl
How do Ruby and Perl compare in function and form?
Method
A subroutine or function associated with a class or object.
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.
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.
Unit Tests
Learn the basics of writing and running unit tests for test driven development in Rails.
What is Ruby on Rails?
What is the Ruby on Rails web framework?
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.
Package Manager
A package manager is software on a Linux system that manages the other software installed on the system.
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.
Making Deep Copies in Ruby
It's often necessary to make a copy of a value in Ruby. While this may seem simple, and it is for simple objects, as soon as you have to make a copy of a data structure with multiple array or hashes on the same object, you will quickly find there are many pitfalls.
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.
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.
Ruby - QuickTips
An index of QuickTips for the Ruby guide site.
Regular Expression
Regular expression is a specialized computer language for matching strings of text.
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.
Test Suites
Grouping your test cases into test suites.
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?
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.
Ruby vs. PHP
What are the similarities and dissimilarities between Ruby and PHP?
Associative Array
A named collection of key/value pairs.
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.
Regex: Grouping
The grouping operators, including the parentheses operator, are some of the most powerful and frequently used operators in the Ruby regex syntax.
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.
Ruby vs. Python
How do Ruby and Python compare in terms of features, form and function?
Sinatra URL Matching
How do do various types of URL matching in Sinatra.
Edit Boxes
A quick tutorial taking you through using edit_line and edit_box elements in Shoes to provide text editing.
Tk Widgets
How to use some of the most basic Tk widgets.
Regular Expression Syntax
The basic syntactical elements of regular expressions in Ruby.
Conditionals
How to use conditional statements in Ruby
Installing Ruby on Windows
A visual walkthrough on installing Ruby on Windows.
Regular Expression Options
Using options to change the behavior of regular expressions.
POST Request
A POST request is used to submit forms or upload files.
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.
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.
Following Updates on Twitter
Learn how to follow Twitter updates using Twitter's openly-provided Ruby API.
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.
Cloud Computing
What is cloud computing? We asked Dave Vandervort of Xerox Innovation Group to help us answer that question and more.
Using Migrations
Using migrations to manage your Ruby on Rails application databases.
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.
Net::SSH Classes
The Net::SSH library contains handy abstractions for most common tasks so you don't always have to think about channels. However, to get the most out of the library, you'll have to learn about channels.
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.
Twitter With Ruby
Now that you have a handle on the Twitter API and parsing the data returned by Twitter, it's time to start tweeting!
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.
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.
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.
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.
Using WxRuby Layout Managers
Arranging widgets in your WxRuby applications can be accomplished more easily by using the layout managers, known as sizers.
Installing wxRuby
wxRuby, a GUI toolkit for Ruby which interfaces with wxWidgets, can be installed on Ubuntu Linux with relative ease.
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.
Using POP3 Libraries
Learn to use Ruby's pre-installed POP3 libraries to check your email.
CSRF Without XSS
CSRF attacks are similar in nature to Cross-Site Scripting (XSS) attacks and can occur in conjunction with an XSS attacks, but they don't always go hand-in-hand and differ in nature. While XSS attacks rely on HTML code injected into the target site, a CSRF attack may also be initiated from a second site.
Top 5 New Features in Ruby 1.9
The 5 most interesting or useful features in the new Ruby 1.9.1 release.
Named Character Classes
A listing of the named character classes available to you in regular expressions in Ruby.
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.
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.
CSRF
Exploitation of a website utilizing the trust the site has for a certain user.
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.
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.
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.
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.
Array
An ordered collection of values, often assigned to a variable. In Ruby, the array takes the place of all ordered collections. They act as arrays, lists, stacks, queues, etc.
Making Tests Pass
Making tests pass in Test-Driven Development is the whole point. So how do you make that happen?
Text and Paragraphs
Since the Shoes GUI is so heavily inspired by the World Wide Web and HTML, it provides a good selection of elements with which you can display text. Here's a tutorial showing you how to use those elements.
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.
The Four Quantifiers
Quantifiers tell how many times an element should be matched. Below is a list of all quantifiers supported by the Ruby regular expression engine, how to use them and examples of their use. Though you can get by with the common quantifiers such as + or ?, there are a few more you should know about.
Ruby - HowTos
An index of HowTos for the Ruby guide site.
Graphical User Interface
A graphical user interface (or GUI) is an interface to a program built with images, words and symbols.
Wirble
The Wirble Gem provides a number of practical features for the IRB, including colorization, which makes reading output much easier.
Adding a Status Bar in WxRuby
Adding a status bar to your WxRuby applications, whether it be to show progress in loading a page or to provide hyperlink information, is as easy as adding a Status Bar object to a Frame.
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.
Using Structs and OpenStructs
Storing key/value pairs in Ruby doesn't always need to be accomplished by using a hash. You can also use the Struct and OpenStruct classes.
The First Test
Learn to start writing Ruby code using Test-Driven Development.
Creating Sub-Menus in WxRuby
Appending sub-menus in WxRuby applications can be used to reduce clutter in large menus and keep everything neat and tidy without overwhelming the user. When the mouse hovers over a sub-menu, another menu pops out to the right, giving a whole sub-set of choices for the user.
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.
Vim
A review of the Vim text editor for writing Ruby code.
Module
In the general sense, a module is a complete software subsystem that can stand on its own. In Ruby, a module is a collection of methods you can use to extend a class.
Command Line Options
There are two forms of command-line options: long form and short form. Both long and short form options take arguments, each a little differently.
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.