1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Ruby: Most Popular Articles

These articles are the most popular over the last month.
A Quick Guide to Creating and Using Hashes in...
This article explains and teaches how to use a associative arrays (hashes) as a way to store multiple variables in one data structure.
How to Fix Missing Class or Module Errors
Problem: You encounter an error reading NameError: uninitialized constant Something or NameError: uninitialized constant Object::Something (with various class names in place of Something).
A Quick Guide to Forming Command Line Arguments...
Use command-line arguments to pass parameters to your Ruby scripts from the command line.
Creating a URL Shortener in Rails
The following is a list of articles that will show you how to write, style and deploy a URL shortener (like TinyURL) application in Ruby on Rails.
What Every Coder Should Know About Running Ruby...
Learn how to use the command line interface on Windows, Linux and OS X to run rb files and use the interactive Ruby program. Page 2.
A Quick Guide to Using Environmental Variables...
Using environment variables in Ruby.
How to Create Arrays in Ruby
This article explains and teaches how to use a arrays as a way to store multiple variables in one data structure.
NameError: undefined local variable or method...
Problem: You encounter an error reading NameError: undefined local variable or method `a' for # or NameError: undefined local variable or method `a' for main:Object (with various identifiers in place of 'a').
How to Use Comments for Ruby Code
Use comments to annotate your Ruby code.
A Quick Guide to Installing Ruby on Linux
How to install Ruby on the Linux operating system.
How to Use 'Ternary' (Conditional) Operators in...
class="no-js" itemscope itemtype="http://schema.org/Article" > itemprop="description" >The ternary (or
How to Use Case (Switch) Statements in Ruby
The case statement is a control structure that is usually quite limited in other programming langauges. However, it's quite powerful and flexible in Ruby.
Splitting Strings
Unless user input is a single word or number, that input will need to be split, or turned into a list of strings or numbers.
Using the 'split' Method in Ruby
String manipulation using the split method in Ruby. Split strings into a list of substrings.
How to Create a URL Shortener in Ruby on Rails...
URL shortening is a useful feature for any Rails application. Making it easy for people to share links to your content is always a good thing.
Here's What Ruby Is
What type of language is the Ruby programming language?
A Simple Guide to Using the Command Line in Ruby
How to use the command line interface on Windows, Linux and OS X to run Ruby scripts and use the interactive Ruby program.
How to Use OptionParser: Ruby's Powerful...
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.
How to Use 'Loops' in Ruby (While, Until, Each,...
Loops, including while and include loops, are one of the most commonly used constructs in computer programs. Page 2.
How to Use 'DIR.GLOB' with Directories in Ruby
In the previous article in this series, we discussed the basics of the Dir class. Particularly useful was the Dir.for each method for iterating over all files in a directory. However, this only goes so far. What if you want to iterate over only some files (for example, just XML files) in a directory?
Generating Random Numbers in Ruby
It's often useful in games, simulation and unit testing to generate random numbers, Ruby provides easy access to a pseudo-random number generator.
Using Attributes
There are two basic things you can do with an object: call a method on it and access an attribute. Ruby doesn't make a distinction between these things, but it does give you some tools to make some methods act like attributes.
A Simple Guide to Using Aliases in Ruby
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.
How to Install JSON Gem in Ruby
It's easy to jump into parsing and generating JSON in Ruby with the json gem. It provides an API for parsing JSON from text as well as generating JSON text from arbitrary Ruby objects. It's easily the most used JSON library in Ruby.
RubyMine 5.0
I've always been a Vim person. Just give me a good solid editor and I'll take it from there. But I decided to give RubyMine a good honest try, and here's what I think about it.
Ruby on Rails Blog Tutoriall - Allowing Comments
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.
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.
Two Dimensional Arrays in Ruby
We'll use a two dimensional array to represent the 2048 game board, but how do we create a 2D array in Ruby?
Symbols are everywhere in Ruby code but, having no analog in other programming languages, they're often misunderstood.
Instance Variables
Instance variables are some of the most common and important variables types in Ruby. They begin with the at sign (@) and allow objects to track their internal state.
Global Variables
Global variables are not often used in Ruby, however, you should at least understand their usage should you ever encounter them.
List of Rack Middleware
The following is a list of Rack middleware applications that come with the Rack gem. A brief description of each middleware is given.
Net::SSH--The SSH (Secure Shell) Protocol
Net::SSH is a way for Ruby to interact with SSH (Secure Shell) protocol. It relies on the OpenSSL library for encryption.
Using the Logger Library--How to Write Log...
How to use the logger library to create and write to log files in Ruby.
How to Use 'OptionParser' for Command Parsing...
Using OptionParser to parse command line options is a preferable alternative to GetoptLong or looking through ARGV manually. But how do you use it?
3 Ruby Scripts for Twitter Automation
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.
Installing Ruby Version Manager on Linux
Installing the Ruby Version Manager (RVM) on Linux
How to Install and Use Ruby's Tk Toolkit
Directions of how to install the Tk GUI and its Ruby bindings on Windows, Linux and Mac OS X.
Making a Text Adventure Game in Ruby
Text adventure games were a very popular game genre on minicomputers and microcomputers from the 1970's through the 1990's. This article series will take you through each step of making a text adventure game in Ruby.
How to Install Gems from Git Repositories in Ruby
How to install gems from git repositories.
Wondering if You Should Overlook The "Require"...
The 'require' method is the reusable code mechanism in Ruby. It allows you to import other source files into your programs.
How to Use String Substitution in Ruby
class="no-js" itemscope itemtype="http://schema.org/Article" > itemprop="description" >Splitting a string
Importance of Strings and Substrings in Ruby
Using and manipulating strings and substrings in Ruby.
Constant Variables
class="no-js" itemscope itemtype="http://schema.org/Article" > itemprop="description" >The speed of light
Quick Rails 4 Blog Tutorial
What do you do when a new version of Rails comes out? Build a blog, of course. The blog is kind of the hello, world application of the web application world.
Understanding 'String Literals' in Ruby
The basics of strings, string interpolation, single and double quotes, escape sequences and alternate string literal syntaxes.
Instantiation and the Initialize Method
Ruby objects are instantiated using the Class.new method, and initialize using their own initialize methods.
What is Ruby?
New to Ruby? Or even to programming? Find out what Ruby really is (and isn't) and why you should (and shouldn't) use it.
Benefits and Risks of Living in the Cloud for...
What is cloud computing? Interviews with industry experts help us define cloud computing, software as service, platform as service and more.
How Does Ruby Compare to Python?
How do Ruby and Python compare in terms of features, form and function?
Boolean Operators
While simple boolean expressions will get you pretty far, you'll soon find yourself wanting to act on more than one condition. For that you'll need boolean operators.
Overloading Operators
What does a + b mean? That all depends on what 'a' is. Ruby allows you to define a number of arithmetic operators and they're called on the left-hand side of any such expression.
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.
Update Twitter From an RSS Feed
This Ruby script for Twitter is what's often referred to as a "mashup." Mashups interface one protocol
What's New in Ruby 1.9.1? -The Lambda Operator
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.
The Algorithm
Before we start coding, we take some time to look at the game of 2048.
What is Rack?
There’s a lot of talk about Rack , but unless you’re a framework author yourself, you rarely see it. So what is Rack? And why, as an application developer, should you care about it?
extconf.rb:1:in `require': no such file to load...
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.
How Does Ruby Compare to the Java Programming...
What features do Ruby and the Java programming language share? How are they alike and how are they different?
CSV Example: Parsing CSV
A crash course on what CSV is, what it is used for and how it is parsed. A method for parsing CSV files using only Ruby's built-in string methods is presented and discussed.
RVM and 'sudo'
RVM is great. However, there may be times where you must run Ruby scripts with RVM as root (or another user) via sudo.
Adding Files to a Repository
How to add files to a Git repository.
How to Install Ruby
How to install the Ruby interpreter on Windows, Linux and OS X.
Be Notified of New Twitter Updates by IM
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.
What is Ruby on Rails?
Learn about the concepts of Ruby on Rails, a Model-View-Controller framework for creating database-driven websites in Ruby.
Indexing Strings
When strings are used for output, they're often viewed as single immutable blocks of text. Once you form the string using string literals and interpolation, it often is simply output or stored in a variable to be output later. However, when strings are used as input, they're not usually taken at face value.
What is Bundler?
Bundler is a gem dependency manager for Ruby.
Combining Arrays in Ruby
There are a number of ways to combine arrays in Ruby.
Mouse and Keyboard Input in Gosu
Games are, by definition, interactive. Gosu makes this interaction straightforward with a simple interface for detecting and reacting to key and mouse button presses.
What is ActiveRecord?
What is ActiveRecord? What can you do with it?
Getting Started with Bundler
The basics of using Bundler are very trivial, you can be up and running in just a few minutes.
Can I add empty directories to Git repositories?
Can I add empty directories to Git repositories?
What's New in Rails 4?
Now that Rails 4 is out, let's see what's new.
Logging what Mechanize Does
class="no-js" itemscope itemtype="http://schema.org/Article" > itemprop="description" >In order to analyze
How to Install Ruby's Development Environment...
In the past, the Ruby “One-Click Installer” was the primary choice for installing Ruby on Windows. However, the One-Click Installer fell into disrepair and was eventually abandoned. Something new was needed, and thus, RubyInstaller was born.
Net:SSH--Transferring Files with Net::SCP
SSH is not just for running commands, 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.
Structure of a JSON Document
JSON is a data serialization format for communicating between applications. It's a text format that features a lightweight syntax and closely mirrors the common data structures in modern programming languages.
Base64 in Ruby
Base64 is a way to represent any data as ASCII data. Ruby provides a few handy functions to encode and decode Base64.
Using Git With Ruby on Rails
You don't have to use version control, but you should be. In the past, version control software has been large, clunky, required servers and really was only used when working in groups. But with Git, it's so easy that you really have no excuse, you should be using version control.
25 Gem Commands for RubyGems
The gem command is one of the most used Ruby-related commands. This article shows 25 Gem Commands and their functions.
The 10 Fantastic Free Ways to Learn Ruby
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.
Embedding Images in Gosu Programs
Games can rarely run from a single file. Even if all of the game's code fits in a single file, there's bound to be image and sound data that accompanies it. Traditionally, to distribute a game, you zip the code and data up in a zip archive and distribute this file. However, sending a zip file isn't very transparent, and you often need a file hosting service to host the zip file.
Block Parameters and Yielding
class="no-js" itemscope itemtype="http://schema.org/Article" > itemprop="description" >Block parameters
A Beginner's Guide to Creating a Blog in Ruby
Part one of the Ruby on Rails blog tutorial focuses on creating a Rails project and scaffolding a basic blog post data structure.
Net:SSH--Executing Programs with Net::SSH
Running programs with Net::SSH is simple enough. The Session object gives you two convenient methods with which to accomplish this task.
Cryptographic Hashes in Ruby
Generating cryptographic hashes in Ruby is quite easy. Ruby provides both a built in method and gives access to OpenSSL's hashing algorithms in most installations.
NoSQL and Document Oriented Databases
Chances are, you've spent your entire database life with relational databases. Data gets organized into columns, and stored in rows. You manipulate data with SQL (Structured Query Language) and there's really no other way to do it. There are competing SQL servers out there (MySQL, SQLite, etc), but they all more or less operate in the same way. But there's much more out there than SQL databases, especially with all the new software in the past few years.
Load Vs. Require
You probably know about the 'require' method (yes, it is a method, it's not a keyword), but what about the 'load' method? What's so different about it?
Worked Example: Number Guessing Game
A number guessing game is written, and each of its features explored.
Doing Things Wrong in Ruby: Number Guessing...
Doing things wrong in Ruby: to to (and how not to) write a number guessing game in Ruby.
Conditional Statements
Conditional statements are what makes computer programs tick. Without conditional statements, all computer programs would follow the same path from beginning to end.
Eval: Running Code on the Fly
Most non-compiled languages have some kind of eval function, which will take a string and execute it as code.
Rails Application Flow
When you program with any framework, you relinquish flow control in favor of convenience. The following is a description of what happens to a request as it passes through Ruby on Rails.
Step 1: Scaffolding Posts
Without a framework like Rails, and particularly the scaffold generator, getting up and running with any project was a pain. You'd be doing a lot of configuring and planning and typing out all the methods to create blog posts and interact with the database. Rails does all this in just a few commands, and while it's not something you'll want to deploy right away, it does give you an excellent starting point.
4 Ways Ruby is Better Than Your Programming...
A comparison of Ruby to other programming languages, including Perl, Java, Python and PHP.
Basic Array Operations
Beyond creating arrays using literals, there are a few things you should know to get by with Arrays.
Constants in Ruby
Like just about every programming language every conceived, Ruby supports constants. A constant is a variable whose value cannot be changed. However, in Ruby, this has some caveats.
Can't Modify Frozen String
I'm trying to modify a frozen string, but I keep getting this exception. Why?
How to Display Your Ruby Version in Your Bash...
With RVM installed on your system, it's easy to have many versions of Ruby installed. And, especially if you switch between them often, it's easy to forget which Bash command prompt is using which Ruby version. You can solve this by putting your Ruby version in your Bash prompt.
Install Ruby on Windows
How to install the Ruby interpreter on the Windows operating system.
An Introduction to 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.
Reference: Named Character Classes
A listing of the named character classes available to you in regular expressions in Ruby.
Agile Development
The principles of Agile Development and how agile applies to Ruby on Rails.
Serialization in Ruby: Marshal
Serializing an object is to convert an object to a byte stream and either store that object for future loading, or sending to another program to be loaded there. There are several common ways to serialize objects in Ruby. The Marshal module is used less often than the other methods, but it's included in the standard library.
How to Install 'Git' on Windows
Installing command line tools such a Git on Windows is often difficult. Not only do you have to find a Windows port or attempt to compile the tool yourself from C source code, you also have to deal with the Windows command line. The Windows command line is, to say the least, a little lacking. Windows users are in luck here though, the MSysGit project solves both these problems.
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.
Using Haml with Sinatra
How to use Haml to create Sinatra views and layouts.
One Tree to Rule Them All
Some problems seem difficult, there are just too many things to consider and it's going to become a mess. However, if you analyze it, there's often a single data structure that will make the whole thing easier.
Using the Enumerable Module
By using the Enumerable module, you can make any of your classes act like Ruby standard collections. All you need to do is implement the 'each' method.
Part 3: Implementing
In this part, we'll implement a complete working application.
Automatically Following Followers on Twitter
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.
Markup Language
A markup language is special syntax to define the structure and formatting of a document.
Mechanize Error: Mechanize::UnsupportedSchemeEr...
The error Mechanize::UnsupportedSchemeError is raised when Mechanize tries to fetch a page using an unsupported protocol scheme, such as ftp or gopher. Mechanize supports only the file, http and https schemes.
Iterating Over Strings
It's not a very common thing in Ruby. You have more sophisticated string tools (such as split or scan), but there are times when you'd want to iterate over the characters in a string. Unicode complicates this matter, but Ruby makes it simple.
How to Use the Twitter Gem for Ruby
Using the Twitter RubyGem, making API requests to Twitter is even easier than using the twitter method.
Using Rack
In the previous article, you learned what Rack is. Now, it’s time to start using Rack and serve up some pages.
: Classes, modules and methods are defined in Ruby with the keywords class , module and def respectively.
Hash Tips and Tricks
Hashes aren't just data structures, they have a few tricks up their sleeves. And while you may never end up using any of these tricks, they really show off how flexible the Hash class is.
Reading Files
Ruby programs rarely exist in their own little world. And while many choose to communicate over the internet, there's still plenty of need to access plain old files.
Package Manager
A package manager is software on a Linux system that manages the other software installed on the system.
5 Must Know Features of the Ruby Language
If you're going to program in the Ruby language, there are some basic features you absolutely must know. Here are the Top 5.
Optional Method Parameters with Hashes
Using hashes to simulate optional named parameters in methods.
XSS (Cross-Site Scripting) Vulnerabilities in...
Every web developer has to worry about security. There are attackers poking at your site all the time, and the last thing you want them to find is a vulnerability. But Ruby has your back, and has largely mitigated XSS attacks.
Unit Testing with Minitest: Basic Assertions
Test-Driven development is a popular and powerful development methodology, and Ruby's built in MiniTest library makes this task simple.
How to Use and Create Blocks in Ruby
How to use blocks in Ruby.
Buttons and Submitting Forms
class="no-js" itemscope itemtype="http://schema.org/Article" > itemprop="description" >Buttons primarily
Visual Tutorial: Installing Ruby on Windows
A visual walkthrough on installing Ruby on Windows.
The Mechanize 2.0 Handbook
Mechanize is a library for automated interaction with web sites. For all intents and purposes, it acts like a web browser with no user interface. It downloads web pages, can click on links, fill out and submit forms, store cookies, etc. Mechanize is useful for automated crawling, testing and scraping of web sites.
undefined method `to_sym' for nil:NilClass
Problem: Seemingly 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.
Test Driven Development in Ruby--Assertions
The Test::Unit library comes with a variety of assertions to make writing tests much easier. Learn what the assertions are for Test-Driven Development and when to use them.
Keyword Arguments
Until Ruby 2.0, Ruby has not had true keyword arguments. You could simulate them using a hash, but as of Ruby 2.0 there's no longer any need to do that.
ARGF, a Shortcut for Scripts
A common task for command line scripts is to read all files listed on the command line, and Ruby has a shortcut for that: the ARGF object.
Committing Changes
The Git repository tracks the status of all files in your project. However, it doesn't know exactly what you've done until you commit your changes. Committing changes tells Git to look at all the files, find the changes you made as well as any new files and integrate them all into the Git repository. Until you make a commit, any changes made are in limbo and not yet part of the repository.
Creating Hashes from Arrays
How do you create hashes from tabular data? There are a few ways, but there's a way built into Ruby that fits onto a single line.
How Use RMV to Install Ruby On OS X Snow Leopard
So, you've gotten your shiny new Mac and you want to get right into Ruby programming , where how do you
Variables Declared in the Global Scope
I declared a variable in the global scope, and now I can't access it. What's going on here?
Hello, Sinatra! Using Sinatra in Ruby
How to get started in Sinatra, including how to use actions, parameters, ERB and views.
Overlooking Input and Output? Using the Input /...
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.
Garbage Collection
Garbage collection is the process of freeing unused objects. It's a hallmark of many high level languages, including Ruby.
How Does Ruby Compare to PHP?
What are the similarities and dissimilarities between Ruby and PHP?
AJAX With Sinatra
In this article we take a look at how to use jQuery and Sinatra to implement an AJAX interface.
Are You Sure You Want to Exit? and Other Dialog...
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.
Class Variables
Class variables in Ruby are more or less as you'd expect form an object oriented language. However, Ruby throws you a curveball you can use to your advantage.
Why JRuby?
As a Rubyist you probably know and love the official Ruby implementation. It's very stable and capable, so why should you use JRuby?
Ruby has a the usual and expect loops, as well as a number of loops specific to Ruby. It even has a way to define you own types of loops.
Installing Gosu
While Gosu does require native compilation, the developers thankfully require pre-compiled packages for all platforms. On Windows, Linux and OS X, Gosu can be installed with a single gem command.
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.
An Introduction to Rails: a Quick Blog Part 1
It can be quite difficult to orient yourself for the first time in the Ruby on Rails world. This two-part tutorial should get you up and running, but is far from a comprehensive tutorial.
Progress Bars with the ruby-progressbar Gem
How to use the ruby-progressbar gem to display progress bars on the command line.
Explore Ruby
By Category
    rubyRubycomputeTechbc50405f6500016666800be03c53ced14a0007b41c0042dbhttp://ruby.about.comod526F6F7444924liveMichael MorinrubyguideLmC0001qzNIP11970-01-0110/od/index.htm0526F6F741approved/od
  1. About.com
  2. Tech
  3. Ruby

©2015 About.com. All rights reserved.