background preloader

Ruby

Facebook Twitter

Cucumber - Making BDD fun. Ruby Cloud Platform as a Service. Ruby QuickRef. Table of Contents Language General Tips These are tips I’ve given over and over and over and over… Use 2 space indent, no tabs. Use [] over Array.new. See for more. General Syntax Rules Comments start with a pound/sharp (#) character and go to EOL.

Reserved Words alias and BEGIN begin break case class def defined? Types Basic types are numbers, strings, ranges, regexen, symbols, arrays, and hashes. Numbers 1231_234123.451.2e-30xffff 0b01011 0377 ? Strings In all of the %() cases below, you may use any matching characters or any single character for delimiters. %[], %!! 'no interpolation'"#{interpolation}, and backslashes\n"%q(no interpolation)%Q(interpolation and backslashes)%(interpolation and backslashes)`echo command interpretation with interpolation and backslashes`%x(echo command interpretation with interpolation and backslashes) Backslashes: Here Docs: Encodings: Waaaay too much to cover here.

Symbols Internalized String. 1.8: Symbols may not contain \0 or be empty. Ranges 1..101...10'a'..' Regexen. AWK-ward Ruby. This essay was to be published as a companion piece to The Shell Hater's Handbook, an introductory talk on UNIX shell programming for Ruby hackers given at GoGaRuCo 2010.

AWK-ward Ruby

Alas, the post-conference wrap up magazine will not be published this year and so I'm making the essay available here instead. Ruby, like most successful languages, was assembled from pieces of things that came before it: Smalltalk's consistent object system, Perl's practical syntax, UNIX's sensibilities. Not that it didn't bring entirely new innovations (block syntax! Smalltalk had block syntax first!) Of its own, but it's amazing to consider how much of Ruby's design rests on the elegant packaging of old concepts into a new coherent whole.

There's something less obvious but perhaps more essential that Ruby borrowed: the very concept of blatant, unashamed borrowing. Or did it? If these features didn't originate with Perl, as Wall seems to imply, then where did they come from? Cat /etc/passwd | awk -F: '{ print $1 }' Ruby QuickRef. Table of Contents Language General Tips These are tips I’ve given over and over and over and over… Use 2 space indent, no tabs.

Ruby QuickRef

Use [] over Array.new. See for more. General Syntax Rules Comments start with a pound/sharp (#) character and go to EOL. Reserved Words alias and BEGIN begin break case class def defined? Types Basic types are numbers, strings, ranges, regexen, symbols, arrays, and hashes. Numbers 1231_234123.451.2e-30xffff 0b01011 0377 ? Strings In all of the %() cases below, you may use any matching characters or any single character for delimiters. %[], %!! 'no interpolation'"#{interpolation}, and backslashes\n"%q(no interpolation)%Q(interpolation and backslashes)%(interpolation and backslashes)`echo command interpretation with interpolation and backslashes`%x(echo command interpretation with interpolation and backslashes) Ruby From Other Languages. When you first look at some Ruby code, it will likely remind you of other programming languages you’ve used.

Ruby From Other Languages

This is on purpose. Much of the syntax is familiar to users of Perl, Python, and Java (among other languages), so if you’ve used those, learning Ruby will be a piece of cake. This document contains two major sections. The first attempts to be a rapid-fire summary of what you can expect to see when going from language X to Ruby. The second section tackles the major language features and how they might compare to what you’re already familiar with. What to Expect: Language X to Ruby Important Language Features And Some Gotchas Here are some pointers and hints on major Ruby features you’ll see while learning Ruby. Iteration Two Ruby features that are a bit unlike what you may have seen before, and which take some getting used to, are “blocks” and iterators. Some_list.each do |this_item| # We're inside the block. # deal with this_item.end Everything has a value Everything is an Object.

Rails

RVM: Ruby Version Manager - RVM Ruby Version Manager - Documentation.