Learn Why to Code

A brief introduction to practical programming

Installing Ruby

The problem: How do we install Ruby and run Ruby programs?
The solution: With Google, StackOverflow, and a little patience.

This is just a skeleton of the actual lesson. Content is added as it is edited and polished.

This will likely be the most painful, least fun part of the lesson. If you are planning to take the ONA class, I strongly suggest you get this squared away. I will try to finish this chapter as quickly as possible. In the meantime, Googling plain-language questions about Ruby installation

I wrote a detailed, but now slightly-outdated primer on installation for the BBoRuby

After installing Ruby (1.8 or 1.9 should be fine) and the HTTParty and FasterCSV rubygems, you should be able to run this script without raising any errors:

A script to test your Ruby installation (test-script.rb) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'rubygems'
require 'json'
require 'fastercsv'
require 'httparty'

puts "Hello world"

url = "http://learnwhytocode.danwin.com"
puts "Testing HTTParty...fetching #{url}"
puts "(you need to be online for this)"

response = HTTParty.get(url)
puts "\n#{response.length} bytes downloaded from #{url}."

puts "\n * Script is done."

For Mac users

Good news. If you’re using Mac OS X from 10.5 (Leopard) on, Ruby is pre-installed on your computer.

If you want to get advanced, you can follow the excellent instructions here. It’s actually a lot of copy-and-pasting and downloading dependencies and following the steps.

For Windows Users

(todo)

Installing RubyGems

(todo)

How to run a Ruby program

(todo)

Interactive Ruby

(todo)

“Hello World”

(todo)

Running programs in the text-editor

(todo)

Comments