Learn Ruby. Iwanttolearnruby.
RubyDoc.info: Documenting RubyGems, Stdlib, and GitHub Projects. RubyGems.org | your community gem host. Bbatsov/ruby-style-guide. Bbatsov/ruby-style-guide · GitHub. RubyIdioms - tokland - Ruby conventions and idioms - My personal repository for code and documentation. This document shows some Ruby idioms, conventions and patterns, most of them accepted by the community, some of them personal. This is a work in progress, so feel free to email me or add a comment if you have any suggestion (tokland AT gmail.com). General formatting Choose a formatting style with readability as first goal, and stick to it. At the same time, break the rules when necessary ("a foolish consistency is the hobgoblin of little minds").
Novice programmers tend to overlook the importance of how the code looks, but as it's been extensively remarked, source code is meant for other people to read and understand, and only incidentally for machines to execute. Indentation Use 2 spaces, no tabs, and never mix spaces and tabs. Whitespaces Put an space after a comma: def method(x, y) [x, y]end No spaces after or before a (, [ or { (when it's a hash): array = [1, 2, 3] hash = {:a => 1, :b => 2} def method(arg1, arg2, arg3) # method bodyend But use spaces to let the blocks breathe: Naming Blank lines. Practicing Ruby | Delightful lessons for dedicated programmers. Understanding Ruby Singleton Classes - Devalot. If you learned object oriented programming from one of the more static languages such as C++ or Java, the dynamic nature of Ruby may seem magical and elusive. After running into the syntax dedicated to meta-programming you may have been left scratching your head or at least wondering what’s happening behind the scenes.
Singleton classes, not to be confused with the singleton design pattern, can easily be placed into this head scratching category. The name itself is confusing leading people to create alternative names such as: object-specific classes, anonymous classes, virtual classes, and eigenclasses. Anonymous class is my favorite, but since the source code to the Ruby interpreter uses the term singleton that’s what I’m going to stick with.
Truth be told, singleton classes aren’t really that difficult to understand. Method Dispatching Before we dive into the mysterious singleton underground, let’s step back for a quick refresher on dynamic dispatch in Ruby. Enter the Singleton Class. The Pragmatic Studio Online | Ruby Programming. Introduction to Programming with Python Course Outline.
Redcar. DataMapper - DataMapper. Rubinius : Use Ruby™ Introduction to Ruby. Programming Exercises. Hackety Hack! Treehouse | Library. RubyMonk - Interactive Ruby tutorials. JRuby. Libraries. References. Ruby Programming Language. Ruby Idioms. Android.