Tutorials

Let’s Build a Simple Video Game with JRuby: A Tutorial

Ruby isn't known for its game development chops despite having a handful of interesting libraries suited to it. Java, on the other hand, has a thriving and popular game development scene flooded with powerful libraries, tutorials and forums. Can we drag some of Java's thunder kicking and screaming over to the world of Ruby? Yep! - thanks to JRuby. Let's run through the steps to build a simple 'bat and ball' game now.

Read more →

What Ruby’s ||= (Double Pipe / Or Equals) Really Does

In Rubyists Already Use Monadic Patterns, Dave Fayram made a passing reference to using ||= to set a variable's value if its value were 'Nothing' (false or nil in Ruby). The resulting Reddit quickly picked up on his definition (which was fixed later) and argued about ||='s true meaning which isn't as obvious as many Rubyists think. This spread to Freenode's awesome #ruby-lang IRC channel where I picked it up.

Read more →

Using Ripper to See How Ruby Is Parsing Your Code

In the past couple of months I've seen situations arise where developers aren't entirely sure how Ruby has chosen to interpret their code. Luckily, Ruby 1.9 comes with a built-in library called Ripper that can help solve the problem (there's a 1.8 version too, see later). Here, I give the 30 second rundown on what to do.

Read more →

Writing Parsers in Ruby using Treetop

treetop.pngTreetop is one of the most underrated, yet powerful, Ruby libraries out there. If you want to write a parser, it kicks ass. The only problem is unless you're into reading up about and playing with parsers, it's not always obvious how to get going with them, or Treetop in particular. Luckily Aaron Gough, Toronto-based Ruby developer, comes to our rescue with some great blog posts.

Read more →

A Walkthrough of Ruby In The Web Browser using IronRuby and Silverlight

With Microsoft's IronRuby and Silverlight, Ruby can become a first-class citizen in the browser on Windows, Linux and OS X.. think <script type="text/ruby"> - yes, it's possible! This walkthrough will get you started with using Ruby in the browser for HTML and vector-graphics-based applications. IronRuby enables Web developers to use Ruby to write client-side browser applications and even reuse code between the server and the client.

Read more →

EventMachine: Get Excited By Scalable Non-Blocking I/O

EventMachine is a simple(ish), fast, event-driven I/O library for Ruby. Its goal is to provide highly scalable I/O performance with an easy-to-use API wrapped around the nastiest parts of the process (since typical Ruby coding practices aren't particularly event-driven friendly). Aman Gupta has put together an awesome 114-page deck of slides (also available as a PDF) that walks through EventMachine with lots of practical code examples.

Read more →

Rails 3.0′s ActiveModel: How To Give Ruby Classes Some ActiveRecord Magic

activemodel.gif One of the biggest benefits of bringing Merb developer Yehuda Katz on board to work on Rails 3.0 has been his relentless pursuit of extracting out all of Rails' magical abilities from their monolithic encasings and into separate, manageable chunks. A case in point is ActiveModel, a new library that provides the model related parts of ActiveRecord but without the database requirements.

Read more →

Thinking Functionally In Ruby – A Great Presentation by Tom Stuart

thinkfunc.pngThinking Functionally in Ruby is a talk that British Ruby developer Tom Stuart gave at a recent London Ruby Users Group meeting. In it he covers what functional programming is, why it's a "pretty neat idea," and how to adopt functional programming principles in Ruby. Skills Matter took a video of the entire 47 minute presentation (it's embedded on the right hand side of that page - Flash required.. just been told it might be limited to UK visitors only, if so get the original MP4 file) but there's also a 110 page PDF (1.5MB download) you should have to hand too (with Tom's slides).

Read more →

17 Videos Covering Basic Ruby Techiques

vidgfx.gifTekniqal.com is a site offering a series of 17 Basic Ruby tutorials in screencast form. In a way, it's like Railscasts, but focusing solely on basic Ruby techniques. So far there are 17 tutorials covering basic topics from whitespace and identifiers through to symbols and hashes, but it looks like there'll be more in future.

Read more →

Building a Search Engine in 200ish Lines of Ruby

somesearchthing.jpegSau Sheong Chang works at Yahoo!'s Singapore office. Yahoo! isn't implemented in Ruby, of course, but Sau's made an attempt at implementing a basic search engine in Ruby and has written a pretty interesting, indepth article about the whole process. Sau's search engine is formed of a crawler, indexer, and query system, and uses Hpricot, DataMapper, and Sinatra to get things done. Lots of code, lots of explanations - go read it.

Read more →

Ruby Techniques Revealed: Autoload

monster-with-torch.jpgThere's plenty of stuff in Ruby that I've either not noticed before, noticed but forgotten about, or otherwise failed to realize the utility of. Add to that all the awesome Ruby tricks and techniques I'm seeing in people's code over on Github lately and.. we need a new series here: Ruby Techniques Revealed!

Read more →