Ruby Books

Study Ruby Programming with Free Open-Source Books

Ruby Books

Ruby is a general purpose, scripting, structured, flexible, fully object-oriented programming language developed by Yukihiro “Matz” Matsumoto. It features a fully dynamic type system, which means that the majority of its type checking is performed at run-time rather than at compilation. This stops programmers having to overly worry about integer and string types. Ruby has automatic memory management. The language shares many similar traits with Python, Perl, Lisp, Ada, Eiffel, and Smalltalk.

Ruby’s popularity was enhanced by the Ruby on Rails framework, a full-stack web framework which has been used to create many popular applications including Basecamp, GitHub, Shopify, Airbnb, Twitch, SoundCloud, Hulu, Zendesk, Square, and Highrise.

Ruby possesses a high portability running on Linux, Windows, Mac OS X, Cygwin, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, Tru64 UNIX, HP-UX, and many other operating systems. The TIOBE Programming Community index currently ranks Ruby in 12th place.

This compilation makes 9 strong recommendations. There are books here for beginner, intermediate, and advanced programmers. All of the texts are, of course, released under an open source license.

We have published a series covering the best open source programming books for other popular languages. Read them here.

Ruby Best Practices

Ruby Best Practices

By Gregory Brown (328 pages)

Ruby Best Practices is for programmers who want to use Ruby as experienced Rubyists do. Written by the developer of the Ruby project Prawn, this book explains how to design beautiful APIs and domain-specific languages with Ruby, as well as how to work with functional programming ideas and techniques that can simplify your code and make you more productive.

Ruby Best Practices is much more about how to go about solving problems in Ruby than it is about the exact solution you should use. The book is not targeted at the Ruby beginner, and will be of little use to someone new to programming. The book assumes a reasonable technical understanding of Ruby, and some experience in developing software with it.

The book is split into two parts, with eight chapters forming its core and three appendixes included as supplementary material.

This book provides a wealth of information on:

  • Driving Code Through Tests – covers a number testing philosophies and techniques. Use mocks and stubs
  • Designing Beautiful APIs with special focus on Ruby’s secret powers: Flexible argument processing and code blocks
  • Mastering the Dynamic Toolkit showing developers how to build flexible interfaces, implementing per-object behaviour, extending and modifying pre-existing code, and building classes and modules programmatically
  • Text Processing and File Management focusing on regular expressions, working with files, the tempfile standard library, and text-processing strategies
  • Functional Programming Techniques highlighting modular code organisation, memoization, infinite lists, and higher-order procedures
  • Understand how and why things can go wrong explaining how to work with logger
  • Reduce Cultural Barriers by leveraging Ruby’s multilingual capabilities
  • Skillful Project Maintenance

The book is open source, released under the Creative Commons NC-SA license.

I Love Ruby

I Love Ruby

By Karthikeyan A K (246 pages)

I Love Ruby explains fundamental concepts and techniques in greater depth than traditional introductions. This approach provides a solid foundation for writing useful, correct, maintainable, and efficient Ruby code.

Chapters cover:

  • Variables
  • Strings
  • Comparison and Logic
  • Loops
  • Arrays
  • Hashes and Symbols
  • Ranges
  • Functions
  • Variable Scope
  • Classes & Objects
  • Rdoc
  • Modules and Mixins
  • Date and Time
  • Files
  • Proc, Lambdas and Blocks
  • Multi Threading
  • Exception Handling
  • Regular Expressions
  • Gems
  • Meta Programming

Permission is granted to copy, distribute and/or modify the book under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation.

Programming Ruby - The Pragmatic Programmer's Guide

Programming Ruby – The Pragmatic Programmer’s Guide

By David Thomas, Andrew Hunt (HTML)

Programming Ruby is a tutorial and reference for the Ruby programming language. Use Ruby, and you will write better code, be more productive, and make programming a more enjoyable experience.

Topics covered include:

  • Classes, Objects and Variables
  • Containers, Blocks and Iterators
  • Standard Types
  • More about Methods
  • Expressions
  • Exceptions, Catch and Throw
  • Modules
  • Basic Input and Output
  • Threads and Processes
  • When Trouble Strikes
  • Ruby and its World, the Web, Tk, and Microsoft Windows
  • Extending Ruby
  • Reflection, ObjectSpace and Distributed Ruby
  • Standard Library
  • Object-Oriented Design Libraries
  • Network and Web Libraries
  • Embedded Documentation
  • Interactive Ruby Shell

The first edition of this book is released under the Open Publication License, v1.0 or later. An updated Second Edition of this book, covering Ruby 1.8 and including descriptions of all the new libraries is available, but is not released under a freely distributable license.

Why’s (Poignant) Guide to Ruby

Why’s (Poignant) Guide to Ruby

By why the lucky stiff (176 pages)

Why’s (poignant) Guide to Ruby is an introductory book to the Ruby programming language. The book includes some wacky humour and goes off-topic on occasions. The book includes jokes that are known within the Ruby community as well as cartoon characters.

The contents of the book:

  • About this book
  • Kon’nichi wa, Ruby
  • A Quick (and Hopefully Painless) Ride Through Ruby (with Cartoon Foxes): basic introduction to central Ruby concepts
  • Floating Little Leaves of Code: evaluation and values, hashes and lists
  • Them What Make the Rules and Them What Live the Dream: case/when, while/until, variable scope, blocks, methods, class definitions, class attributes, objects, modules, introspection in IRB, dup, self, rbconfig module
  • Downtown: metaprogramming, regular expressions
  • When You Wish Upon a Beard: send method, new methods in existing classes
  • Heaven’s Harp

This book is made available under the Creative Commons Attribution-ShareAlike License.

Ruby Hacking Guide

Ruby Hacking Guide

By Minero Aoki – translated by Vincent Isambart and Clifford Escobar Caoille (HTML)

This book has the following goals:

  • To have knowledge of the structure of Ruby
  • To gain knowledge about language processing systems in general
  • To acquire skills in reading source code

This book has four main parts:

  • Objects
  • Syntactic analysis
  • Evaluation
  • Peripheral around the evaluator

Knowledge about the C language and the basics of object-oriented programming is needed to get the most from the book. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike2.5 license.

The official support site of the original book is i.loveruby.net/ja/rhg/

The Book Of Ruby

The Book Of Ruby

By How Collingbourne (425 pages)

The Book Of Ruby is a free in-depth tutorial to Ruby programming.

The Book Of Ruby is provided in the form of a PDF document in which each chapter is accompanied by ready-to-run source code for all the examples. There is also an Introduction which explains how to use the source code in Ruby In Steel or any other editor/IDE of your choice plus appendices and an index. It concentrates principally on version 1.8.x of the Ruby language.

The book is divided up into bite-sized chunks. Each chapter introduces a theme which is subdivided into sub-topics. Each programming topic is accompanied by one or more small self-contained, ready-to-run Ruby programs.

  • Strings, Numbers, Classes, and Objects – getting and putting input, strings and embedded evaluation, numbers, testing a condition: if … then, local and global variables, classes and objects, instance variables, messages, methods and polymorphism, constructors, and inspecting objects
  • Class Hierarchies, Attributes, and Class Variables – superclasses and subclasses, passing arguments to the superclass, accessor methods, ‘set’ accessors, attribute readers and writers, calling methods of a superclass, and class variables
  • Strings and Ranges – user-defined string delimiters, backquotes, and more
  • Arrays and Hashes – shows how to create a list of objects
  • Loops and Iterators – for loops, blocks, while loops, while modifiers, and until loops
  • Conditional Statements – If..Then..Else, And..Or..Not, If..Elsif, unless, if and unless modifiers, and case statements
  • Methods – class methods, class variables, what are class methods for, ruby constructors, singleton methods, singleton classes, overriding methods and more
  • Passing Arguments and Returning Values – instance methods, class methods, singleton methods, returning values, returning multiple values, default and multiple arguments, assignment and parameter passing, and more
  • Exception Handling – covers rescue, ensure, else, error numbers, retry, and raise
  • Blocks, Procs, and Lambdas – explains why they are special to Ruby
  • Symbols – symbols and strings, symbols and variables, and why symbols should be used
  • Modules and Mixins
  • Files and IO – opening and closing files, files and directories, copying files, directory enquiries, a discursion into recursion, and sorting by size
  • YAML – includes nested sequences, saving YAML data and more
  • Marshal – offers an alternative way of saving and loading data
  • Regular Expressions – making matches, match groups, and more
  • Threads – shows you how to run more than one task at a time
  • Debugging and Testing – covers the interactive ruby shell (IRB.exe), debugging, and unit testing
  • Ruby on Rails – goes through a hands-on guide to create a blog
  • Dynamic Programming – self-modifying programs, eval magic, special types of eval, adding variables and methods, and more

The book is distributed by SapphireSteel Software – developers of the Ruby In Steel IDE for Visual Studio. Readers may copy or distribute the text and programs of The Book Of Ruby (free edition).

 The Little Book of Ruby

The Little Book Of Ruby

By Huw Collingbourne (87 pages)

The Little Book of Ruby is a step-by-step tutorial to programming in Ruby. It guides the reader through the fundamentals of Ruby. It shares content with The Book of Ruby, but aims to be a simpler guide to the main features of Ruby.

Chapters cover:

  • Strings and Methods – including embedded evaluation. Details the syntax to Ruby methods
  • Classes and Objects – explains how to create new types of objects
  • Class Hierarchies – a class which is a ‘special  type ’ of some other class simply ‘inherits’ the features of that other class
  • Accessors, Attributes, Class Variables – accessor methods, attribute readers and writers, attributes create variables, calling methods of a superclass, and class variables are explored
  • Arrays – learn how to create a list of objects: arrays including multi-dimensional arrays,
  • Hashes – create, indexing into a hash, and hash operations are covered
  • Loops and Iterators – for loops, blocks, while loops, while modifiers, and until loops
  • Conditional Statements – If..Then..Else, And..Or..Not, If..Elsif, unless, if and unless modifiers, and case statements
  • Modules and Mixins – including module methods, modules as namespaces, module ‘instance methods’, included modules or ‘mixins’, including modules from files, and pre-defined modules
  • Saving Files, Moving on..

This book can be copied and distributed freely as long as the text is not modified and the copyright notice is retained.

Kestrels, Quirky Birds, and Hopeless Egocentricity

Kestrels, Quirky Birds, and Hopeless Egocentricity

By Reg “raganwald” Braithwaite (123 pages)

Kestrels, Quirky Birds, and Hopeless Egocentricity collects Reg “Raganwald” Braithwaite’s series of essays about Combinatory Logic, Method Combinators, and Ruby Meta-Programing into a convenient e-book.

The book provides a gentle introduction to Combinatory Logic, applied using the Ruby programming language. Combinatory Logic is a mathematical notation that is powerful enough to handle set theory and issues in computability.

In this book, the reader meets some of the standard combinators, and for each one the book explores some of its ramifications when writing programs using the Ruby programming language. In Combinatory Logic, combinators combine and alter each other, and the book’s Ruby examples focus on combining and altering Ruby code. From simple examples like the K Combinator and Ruby’s .tap method, the books works up to meta-programming with aspects and recursive combinators.

The book is published under the MIT license.

Ruby Programming

Ruby Programming

By Wikibooks.org (261 pages)

Ruby is an interpreted, object-oriented programming language.

The book is broken down into several sections and is intended to be read sequentially.

  • Getting started – shows users how to install and begin using Ruby in an environment
  • Basic Ruby – explains the main features of the syntax of Ruby. It covers, amongst other things, strings, encoding, writing methods, classes and objects, and exceptions
  • Ruby Semantic reference
  • Built in classes
  • Available modules covers some of the standard library
  • Intermediate Ruby covers a selection of slightly more advanced topics

This book is published under the Creative Commons Attribution-ShareAlike 3.0 Unported license.


In no particular order, I’ll close with useful free-to-download Ruby programming books which are not released under an open source license.


PROGRAMMING LANGUAGE PROFILES

Ada, Awk, Assembly, Bash, C, C++, C#, Clojure, CoffeeScript, ECMAScript, Erlang, Forth, Fortran, Go, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Logo, Lua, OCaml, Pascal, Perl, PHP, Prolog, Python, R, Ruby, Rust, Scala, Scheme, Scratch, SQL, Swift, TeX, VimL

Leave a Reply