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.
Use command-line arguments to pass parameters to your Ruby scripts from the command line.
Hashes
This article explains and teaches how to use a associative arrays (hashes) as a way to store multiple variables in one data structure.
This article explains and teaches how to use a associative arrays (hashes) as a way to store multiple variables in one data structure.
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.
Learn how to use the command line interface on Windows, Linux and OS X to run rb files and use the interactive Ruby program.
Comments
Use comments to annotate your Ruby code.
Use comments to annotate your Ruby code.
The 'require' Method
The 'require' method is the reusable code mechanism in Ruby. It allows you to import other source files into your programs.
The 'require' method is the reusable code mechanism in Ruby. It allows you to import other source files into your programs.
String Substitution in Ruby
Splitting a string is only one way to manipulate string data. You can also make substitutions to replace
Splitting a string is only one way to manipulate string data. You can also make substitutions to replace
Installing RVM on Linux
Installing the Ruby Version Manager (RVM) on Linux
Installing the Ruby Version Manager (RVM) on Linux
Environment Variables
Using environment variables in Ruby.
Using environment variables in Ruby.
Using RVM Gemsets
One of the most powerful, useful and often overlooked features of RVM is the gemset. A gemset is a separate gem directory, so the gems in one gemset don't conflict with the gems in another gemset.
One of the most powerful, useful and often overlooked features of RVM is the gemset. A gemset is a separate gem directory, so the gems in one gemset don't conflict with the gems in another gemset.
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.
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 'split' Method
String manipulation using the split method in Ruby. Split strings into a list of substrings.
String manipulation using the split method in Ruby. Split strings into a list of substrings.
Arrays
This article explains and teaches how to use a arrays as a way to store multiple variables in one data structure.
This article explains and teaches how to use a arrays as a way to store multiple variables in one data structure.
While, Until, Each and Time
Loops, including while and include loops, are one of the most commonly used constructs in computer programs.
Loops, including while and include loops, are one of the most commonly used constructs in computer programs.
Install Ruby on OS X
How to install Ruby on Apple OS X
How to install Ruby on Apple OS X
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.
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.
Install Ruby on Linux
How to install Ruby on the Linux operating system.
How to install Ruby on the Linux operating system.
Using JSON: The JSON Gem
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.
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.
What is Ruby?
What type of language is the Ruby programming language?
What type of language is the Ruby programming language?
Using Glob with Directories
In the previous article in this series, we discussed the basics of the Dir class. Particularly useful was the Dir.foreach 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?
In the previous article in this series, we discussed the basics of the Dir class. Particularly useful was the Dir.foreach 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?
Adding Files to a Repository
How to add files to a Git repository.
How to add files to a Git repository.
Installing 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.
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.
Installing Ruby
How to install the Ruby interpreter on Windows, Linux and OS X.
How to install the Ruby interpreter on Windows, Linux and OS X.
NameError: uninitialized constant Object::Something
Problem: You encounter an error reading NameError: uninitialized constant Something or NameError: uninitialized constant Object::Something (with various class names in place of Something).
Problem: You encounter an error reading NameError: uninitialized constant Something or NameError: uninitialized constant Object::Something (with various class names in place of Something).
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?
Using OptionParser to parse command line options is a preferable alternative to GetoptLong or looking through ARGV manually. But how do you use it?
Install Ruby on Windows
How to install the Ruby interpreter on the Windows operating system.
How to install the Ruby interpreter on the Windows operating system.
Strings
Using and manipulating strings and substrings in Ruby.
Using and manipulating strings and substrings in Ruby.
The logger Library
How to use the logger library to create and write to log files in Ruby.
How to use the logger library to create and write to log files in Ruby.
Installing Git on Linux
There are multiple ways of installing Git on Linux. Depending on which Linux distribution you're using and whether it provides binary packages for Git, you can either install a binary package or install from source.
There are multiple ways of installing Git on Linux. Depending on which Linux distribution you're using and whether it provides binary packages for Git, you can either install a binary package or install from source.
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.
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.
NameError: undefined local variable or method `a'
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').
Problem: You encounter an error reading NameError: undefined local variable or method `a' for #
Installing Gems from Git
How to install gems from git repositories.
How to install gems from git repositories.
Installing Ruby on Snow Leopard
So, you've gotten your shiny new Mac and you want to get right into Ruby programming , where how do you
So, you've gotten your shiny new Mac and you want to get right into Ruby programming , where how do you
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?
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?
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.
Net::SSH is a way for Ruby to interact with SSH (Secure Shell) protocol. It relies on the OpenSSL library for encryption.
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.
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.
Blocks
How to use blocks in Ruby.
How to use blocks in Ruby.
Tk
Directions of how to install the Tk GUI and its Ruby bindings on Windows, Linux and Mac OS X.
Directions of how to install the Tk GUI and its Ruby bindings on Windows, Linux and Mac OS X.
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.
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.
Debugging Ruby
Debugging Ruby programs using the Ruby debugger.
Debugging Ruby programs using the Ruby debugger.
Using Rack
In the previous article, you learned what Rack is. Now, it’s time to start using Rack and serve up some pages.
In the previous article, you learned what Rack is. Now, it’s time to start using Rack and serve up some pages.
Using Haml with Sinatra
How to use Haml to create Sinatra views and layouts.
How to use Haml to create Sinatra views and layouts.
The Twitter RubyGem
Using the Twitter RubyGem, making API requests to Twitter is even easier than using the twitter method.
Using the Twitter RubyGem, making API requests to Twitter is even easier than using the twitter method.
protect_from_forgery
A feature in Rails that protects against Cross-Site Request Forgery (CSRF) attacks.
A feature in Rails that protects against Cross-Site Request Forgery (CSRF) attacks.
Hello, Sinatra!
How to get started in Sinatra, including how to use actions, parameters, ERB and views.
How to get started in Sinatra, including how to use actions, parameters, ERB and views.
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.
How to use the command line interface on Windows, Linux and OS X to run Ruby scripts and use the interactive Ruby program.
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.
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.
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.
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.
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.
The gem command is one of the most used Ruby-related commands. This article shows 25 Gem Commands and their functions.
no such file to load -- mkmf
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.
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.
The ‘exec’ Method
There are several ways to run other programs in Ruby. There is the system> method, backticks, etc. However, they all spawn new processes. If there is nothing left for your Ruby program to do, it has to sit there wasting memory until the launched program finishes. The exec> method fixes this.
There are several ways to run other programs in Ruby. There is the system> method, backticks, etc. However, they all spawn new processes. If there is nothing left for your Ruby program to do, it has to sit there wasting memory until the launched program finishes. The exec> method fixes this.
DataMapper Introduction
DataMapper is a "Object/Relational Mapper" or ORM. In other words, it maps Ruby objects to database records
DataMapper is a "Object/Relational Mapper" or ORM. In other words, it maps Ruby objects to database records
What is Ruby on Rails?
For about 6 years now, there's been a lot of talk about this thing called "Ruby on Rails." They're saying
For about 6 years now, there's been a lot of talk about this thing called "Ruby on Rails." They're saying
Starting the Blog
Generating a Rails project from which to build an application.
Generating a Rails project from which to build an application.
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.
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.
Ruby Gems
Learn to search the Ruby Gems repository to find gems to add and install to your library.
Learn to search the Ruby Gems repository to find gems to add and install to your library.
NoSQL 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.
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.
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.
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.
Lookahead and Back-references
Using lookahead and back-references to refer to other parts of the regular expression text.
Using lookahead and back-references to refer to other parts of the regular expression text.
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.
RVM is great. However, there may be times where you must run Ruby scripts with RVM as root (or another user) via sudo.
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.
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.
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.
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.
Vim
A review of the Vim text editor for writing Ruby code.
A review of the Vim text editor for writing Ruby code.
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.
Running programs with Net::SSH is simple enough. The Session object gives you two convenient methods with which to accomplish this task.
Defining Cloud Computing
What is cloud computing? Interviews with industry experts help us define cloud computing, software as service, platform as service and more.
What is cloud computing? Interviews with industry experts help us define cloud computing, software as service, platform as service and more.
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.
The Twitter API (Application Programming Interface) in Ruby on Rails is about as simple as you can get. Twitter is a RESTful Rails application.
Web Interface for Gems
So far, we've discussed how to use Sinatra in general, how to handle and route requests, and how to build views using Haml. Before we take the plunge into using data storage with Sinatra, let's put what we've discussed so far into practice. This article explains how to use Sinatra to provide a web interface for a gem.
So far, we've discussed how to use Sinatra in general, how to handle and route requests, and how to build views using Haml. Before we take the plunge into using data storage with Sinatra, let's put what we've discussed so far into practice. This article explains how to use Sinatra to provide a web interface for a gem.
Rapid Game Prototyping in Ruby
Myth: Ruby is unsuitable for game development. It's much too slow, there are no good libraries and it's too hard to deploy your games written in Ruby.
Myth: Ruby is unsuitable for game development. It's much too slow, there are no good libraries and it's too hard to deploy your games written in Ruby.
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.
Most non-compiled languages have some kind of eval function, which will take a string and execute it as code.
Option Hashes
Using hashes to simulate optional named parameters in methods.
Using hashes to simulate optional named parameters in methods.
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.
Distributed Ruby, or DRb, is a library that allows you to communicate with remote Ruby objects and programs, using TCP/IP network protocols.
Ruby on Rails 3 Tutorial: Learn Rails by Example
Ruby on Rails 3 Tutorial: Learn Rails by Example by Michael Hartl is a hands on introduction to not only Ruby on Rails but all the related software and services many Rails developers use such as Git, Github, Heroku and RSpec. There are no long-winded discussions on theory or REST or MVC, each and every part of every chapter is a hands on exercise in building a Rails application. This book is recommended for anyone who prefers a hands on approach to learning.
Ruby on Rails 3 Tutorial: Learn Rails by Example by Michael Hartl is a hands on introduction to not only Ruby on Rails but all the related software and services many Rails developers use such as Git, Github, Heroku and RSpec. There are no long-winded discussions on theory or REST or MVC, each and every part of every chapter is a hands on exercise in building a Rails application. This book is recommended for anyone who prefers a hands on approach to learning.
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.
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.
Installing Rubygame on Windows
A visual tutorial with screenshots showing how to install the Rubygame library on Windows, including installing all needed DLL files.
A visual tutorial with screenshots showing how to install the Rubygame library on Windows, including installing all needed DLL files.
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.
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.
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.
If you're going to program in the Ruby language, there are some basic features you absolutely must know. Here are the Top 5.
Can Git Add Empty Directories?
Can I add empty directories to Git repositories?
Can I add empty directories to Git repositories?
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.
Sinatra is a web framework. Simply put, it's a library that allows you to write web applications with a minimum of red tape.
Builder RubyGem
The Builder library is a Ruby Gem that uses a meta-language to generate HTML, XML or CSS markup.
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!
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!
Running the Ruby Profiler
Running the Ruby profiler to determine which methods are most expensive and which need to be optimized.
Running the Ruby profiler to determine which methods are most expensive and which need to be optimized.
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.
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.
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.
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.
4Ways
A comparison of Ruby to other programming languages, including Perl, Java, Python and PHP.
A comparison of Ruby to other programming languages, including Perl, Java, Python and PHP.
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.
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.
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.
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.
What is RVM?
RVM is the Ruby Version Manager. It allows you to install and manage several different versions and implementations of Ruby on one computer, including the ability to manage different sets of RubyGems one each.
RVM is the Ruby Version Manager. It allows you to install and manage several different versions and implementations of Ruby on one computer, including the ability to manage different sets of RubyGems one each.
Regex: Grouping
The grouping operators, including the parentheses operator, are some of the most powerful and frequently used operators in the Ruby regex syntax.
The grouping operators, including the parentheses operator, are some of the most powerful and frequently used operators in the Ruby regex syntax.
Creating and Distributing Gems with Bundler
Creating Ruby gems has always been a bit of a pain. When you get right down to it, it's not a hard thing to do, but it's easy to forget how if you don't do it often enough. There are quite a few gems to help you write other gems, but if you're using Rails 3, there's already a gem on your system that does this: Bundler.
Creating Ruby gems has always been a bit of a pain. When you get right down to it, it's not a hard thing to do, but it's easy to forget how if you don't do it often enough. There are quite a few gems to help you write other gems, but if you're using Rails 3, there's already a gem on your system that does this: Bundler.
Creating a New Repository
A Git repository is not like a repository in most other version control systems. Normally, you'll have something like a CVS or Subversion server where the repository lives. From that, you'll check out a working copy, make your changes to that and commit them. Git is different though, there is no centralized server.
A Git repository is not like a repository in most other version control systems. Normally, you'll have something like a CVS or Subversion server where the repository lives. From that, you'll check out a working copy, make your changes to that and commit them. Git is different though, there is no centralized server.
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.
Displaying images using the Shoes GUI toolkit is as simple as using the image method. This tutorial walks you through adding images in Shoes.
Ruby vs. Java
What features do Ruby and the Java programming language share? How are they alike and how are they different?
What features do Ruby and the Java programming language share? How are they alike and how are they different?
Using POP3 Libraries
Learn to use Ruby's pre-installed POP3 libraries to check your email.
Learn to use Ruby's pre-installed POP3 libraries to check your email.
Using rails.vim
Editing Rails projects in Vim effectively.
Editing Rails projects in Vim effectively.
Syntax
The syntax of a language is the grammatical rules a program must follow in order to be understood by the interpreter or compiler.
The syntax of a language is the grammatical rules a program must follow in order to be understood by the interpreter or compiler.
Ruby vs. Python
How do Ruby and Python compare in terms of features, form and function?
How do Ruby and Python compare in terms of features, form and function?
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.
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.
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.
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.
Regular Expression Options
Using options to change the behavior of regular expressions.
Using options to change the behavior of regular expressions.
String Literals
The basics of strings, string interpolation, single and double quotes, escape sequences and alternate string literal syntaxes.
The basics of strings, string interpolation, single and double quotes, escape sequences and alternate string literal syntaxes.
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.
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.
Package Manager
A package manager is software on a Linux system that manages the other software installed on the system.
A package manager is software on a Linux system that manages the other software installed on the system.
Simple RSS
The Simple-RSS RubyGem provides a simplified interface for reading RSS and Atom documents.
The Simple-RSS RubyGem provides a simplified interface for reading RSS and Atom documents.
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.
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.
The Case Statement
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.
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.
Working with Directories
Learning how to work with files is one of the first things new Ruby programmers learn. However, how to work with directories of files is something that's often skipped or only lightly touched upon. Ruby does have some powerful mechanisms for working with directories though.
Learning how to work with files is one of the first things new Ruby programmers learn. However, how to work with directories of files is something that's often skipped or only lightly touched upon. Ruby does have some powerful mechanisms for working with directories though.
Transfer 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.
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.
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.
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.
The Ternary (or "Conditional") Operator
The ternary (or "conditional") operator will evaluate an expression and return one value if it's true,
The ternary (or "conditional") operator will evaluate an expression and return one value if it's true,
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.
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.
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.
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.
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.
The following is a list of Rack middleware applications that come with the Rack gem. A brief description of each middleware is given.
Listing Known Rubies
In RVM-speak, a "Ruby" is a version of Ruby either installed or it knows has to install. Before you can
In RVM-speak, a "Ruby" is a version of Ruby either installed or it knows has to install. Before you can
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.
It's often useful in games, simulation and unit testing to generate random numbers, Ruby provides easy access to a pseudo-random number generator.
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.
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.
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!
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. PHP
What are the similarities and dissimilarities between Ruby and PHP?
What are the similarities and dissimilarities between Ruby and PHP?
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.
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.
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.
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.
Using Temporary Files
There are many hidden pitfalls when using temporary files. Ruby's Tempfile class solves many of these.
There are many hidden pitfalls when using temporary files. Ruby's Tempfile class solves many of these.
Upgrading to 1.9.2 Using RVM
If you already have a Ruby like 1.9.2-rc2 installed with a number of gems and want to upgrade to 1.9.2-p0, the following steps will get you there. As expected,RVM makes this quite easy.
If you already have a Ruby like 1.9.2-rc2 installed with a number of gems and want to upgrade to 1.9.2-p0, the following steps will get you there. As expected,RVM makes this quite easy.
Cloud Computing
What is cloud computing? We asked Dave Vandervort of Xerox Innovation Group to help us answer that question and more.
What is cloud computing? We asked Dave Vandervort of Xerox Innovation Group to help us answer that question and more.
Making Digraphs in Ruby
Digraphs are extremely useful for hierarchical data visualization. However, they're not very easy to generate yourself. This is where Graphviz and the Graph gem come in.
Digraphs are extremely useful for hierarchical data visualization. However, they're not very easy to generate yourself. This is where Graphviz and the Graph gem come in.
Check HTTP Referrers
By checking if the server from which the request originates is the same as the server your application runs on, you can determine if the request was generated from your site or not. If an HTTP request lacks a Referer header you can also tell it was generated by hand or from a location where Refererwould make no sense (such as an email client).
By checking if the server from which the request originates is the same as the server your application runs on, you can determine if the request was generated from your site or not. If an HTTP request lacks a Referer header you can also tell it was generated by hand or from a location where Refererwould make no sense (such as an email client).
Sinatra URL Matching
How do do various types of URL matching in Sinatra.
How do do various types of URL matching in Sinatra.
Serialization in Ruby: YAML
YAML (YAML Ain't Markup Language) is perhaps the most common form of serialization in Ruby applications. It's used for configuration files in Rails and other projects, and is nearly ubiquitous. It also has distinct advantages over marshal, and is usually preferred.
YAML (YAML Ain't Markup Language) is perhaps the most common form of serialization in Ruby applications. It's used for configuration files in Rails and other projects, and is nearly ubiquitous. It also has distinct advantages over marshal, and is usually preferred.
The Zen of Learning Ruby
Learning Ruby isn't often thought of as a Zen exercise, but that's exactly how the guys at EdgeCase saw it. Thus RubyKoans was born.
Learning Ruby isn't often thought of as a Zen exercise, but that's exactly how the guys at EdgeCase saw it. Thus RubyKoans was born.
Everything You Need to Know About Variables
Variables are named references to objects in memory. Their several variants (local, instance, class, constant, etc) each have their own subtleties.
Variables are named references to objects in memory. Their several variants (local, instance, class, constant, etc) each have their own subtleties.
Loops
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.
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.
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.
Base64 is a way to represent any data as ASCII data. Ruby provides a few handy functions to encode and decode Base64.
Learn to Use Regex in Ruby
What is a regular expression and how do you use them in Ruby?
What is a regular expression and how do you use them in Ruby?
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!
Now that you have a handle on the Twitter API and parsing the data returned by Twitter, it's time to start tweeting!
Ruby vs. Perl
How do Ruby and Perl compare in function and form?
How do Ruby and Perl compare in function and form?
The First Test
Learn to start writing Ruby code using Test-Driven Development.
Learn to start writing Ruby code using Test-Driven Development.
GeoIP
Using GeoIP databases to correlate IP addresses and physical locations using the GeoIP gem.
Using GeoIP databases to correlate IP addresses and physical locations using the GeoIP gem.
Send Email with Ruby
How to send email with Ruby on Rails using SMTP.
How to send email with Ruby on Rails using SMTP.
Interfacing with the Arduino
How to interface with the Arduino's serial port on Linux.
How to interface with the Arduino's serial port on Linux.
The Mechanize Agent
Mechanize can be configured to use HTTP proxies. Some network configurations require you to use HTTP
Mechanize can be configured to use HTTP proxies. Some network configurations require you to use HTTP
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 main loop is the heartbeat of any game, and is the first thing you need to learn to start making your own games.
Installation Instructions
Instructions for installing Ruby on Windows, Mac OS X and Linux as well as instructions for installing a few Ruby-related extras.
Instructions for installing Ruby on Windows, Mac OS X and Linux as well as instructions for installing a few Ruby-related extras.
The Page Class
Most likely, you'll be wanting to find links and click on them. There are three methods that help you
Most likely, you'll be wanting to find links and click on them. There are three methods that help you
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.
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 RubyGems: Cheat
Using the RubyGem 'cheat' for access to wiki-like cheat sheets.
Using the RubyGem 'cheat' for access to wiki-like cheat sheets.
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.
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.
CSRF
Exploitation of a website utilizing the trust the site has for a certain user.
Exploitation of a website utilizing the trust the site has for a certain user.
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.
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.
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.
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.
Unit Tests
Learn the basics of writing and running unit tests for test driven development in Rails.
Learn the basics of writing and running unit tests for test driven development in Rails.
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.
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.
Ruby Version in Your Bash Prompt
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.
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.
Checking Your Email with Ruby
How to check POP3 email accounts in Ruby.
How to check POP3 email accounts in Ruby.
