julianeon/API-Examples-Ruby — pull request #1 by theckman (2014-07-04 02:16:08+00:00)
Title: make Ruby API examples more idiomatic

This huge patch makes adjustments to all Ruby source files. The code was adjusted to be readable and fit within the common Ruby idioms. The Rubocop linter was used, with default configuration, to report any style errors.

The following style items were address:

* Adding spaces around an assignment operator

So when assigning a variable, it should have spaces around the `=` symbol. For hashes, there should be a space between the key and the value: `{ key: 'value' }`

* shebang + encoding

This adds a proper Ruby shebang and encoding comment at the top. The latter is a Rubocop thing, but still good to have.

* Ruby 1.9-style hashes

For 1.9, the hashes had the following syntax: `{ :key => 'value' }`, in Ruby 1.9 you can do: `{ key: 'value' }`

* Proper indenting

This is making sure that each indentation level is a multiple of 2 spaces, with 0 being the minimum. This also makes sure that all indentation is consistent everywhere.

* Trailing whitespace

Remove any whitespace at the end of the line, or just random whitespace in the middle of the file

* Make sure things that are being treated as constant are defined as a constant

Constant definition in Ruby isn't a hard constant, you can overwrite it but Ruby will warn. It's usually best form to define constants as constants. To do so in Ruby, just make your variable name consist of all capital letters:

```Ruby
CONTSTANT_HERE = :ohai
```

* Use single quotes when there is no String interpolation

If you aren't trying to print the contents of a variable in a string (e.g, `puts "hello #{person_name}"`), you should use single quotes:

`'Hello'` instead of `"Hello"`. However, due to interpolation being needed this won't work: `'Greetings #{name}!'`

* Unused variables

There were quite a few variables that were just hanging around; this could make the examples more confusing to understand. I just removed these to improve readability.

This also removes the lingering API keys and subdomain names.