RUBY

I was having a little time on my hands and I thought I would try looking at Ruby.

Ruby is installed with OSX.

(I’ll post these links and information and tidy and format them up later. )

I’ve used the dollar sign $ to indicate the following text is to be entered into the Terminal window.

Links:

See: guide

download

introduction

expansion pack:

How To Install Ruby on OS X

Ruby One-Click Installer for OSX

1. Download Ruby and place in Applications folder

2. Open the terminal

3. Launch Ruby and see prompt:

$ irb –simple-prompt

>>

4. To create a Hello World application

I created a new folder – ruby in my Workspace

Created the following in a textfile:

puts “Hello World”

saved as hello.rb in the ruby folder.

in the Terminal window:

$ cd to workspace/ruby

$ ruby hello.rb

And Voila:

“Hello World”

appears in the terminal window!

5. To make make executable:

add:

#!

(pronounced “sharp bang”) to the first line of the HelloWorld file

to make:

#! /usr/bin/ruby

puts “Hello World”

6. The file needs to be ‘modified’ before the app can run:

$ chmod +x hello.rb

( And ./ has to precede the fie name. )

$ ./hello.rb

The Terminal outputs:

“Hello World”

6. EXAMPLES OF RUBY COMMANDS:

$ ri

can give you information about a class.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s