Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
106 lines (82 sloc) 3.68 KB
http://stackoverflow.com/questions/49092/online-interactive-consoles
http://tryruby.org/
http://www.codecademy.com/#!/exercise/0
- develop lesson plan before the date
Installation on windows
- Navigate to rubyinstaller.org
- Click the link 'Ruby 1.9.2-p290' to download the latest stable version
- Once the file is downloaded, double-click on rubyinstaller-1.9.2-p290.exe
- Once setup is running, click 'I accept the License'
- Click 'Next'
- Do not change the default install directory, C:\Ruby192
- Check off 'Add Ruby executables to your PATH'
- Check off 'Associate .rb and .rbw files with this Ruby installation'
- Click 'Install'
- Click 'Finish' when you see the completion window
What is Ruby? - don't dwell on this too much
- A programming language
- Talk to your computer via a programming language
- Examples of common web apps the they would know in Ruby
- Screenshots of apps
- Easy on the developer
- Show C#/Java example vs Ruby example
- Think of Rails example, try and explain framework vs. language
Starting the console (OS X)
- Applications -> Terminal
Starting the console (Windows)
- Click 'Start' -> 'All Programs' -> 'Accessories' -> 'Command Prompt' (C:\windows\system32\cmd.exe)
Integers
- Numbers without decimals
Running ruby
- Type ruby -v
- You should see ruby 1.9.2p290 followed by other information
- Type irb to enter the ruby console
- Type 1 + 2
- See the result 2 printed to the screen
- Type 2 * 5
- You can see the Ruby can perform calculations
- You've just met your first data type! An integer.
- Why Ruby?
- This is what you can do, this is what we're going to do
- THINK OF ANALOGIES THE ENTIRE TIME!
What are data types?
- Look at the two words separately: data and type
- Data can be a word, a collection of words, a number, an integer, a decimal, or anything you would traditionally think of as data
- Type refers to the kind of data that is provided; important because you have to be able to tell the computer what you expect to be able to do with the data you provide it
- For instance, try typing 1 + 5 and then try typing 'ladies' + 'learning' + 'code'
- Let's break down the two statements you just typed
- Each one is made up of data and an operator
- The data between the first and second is different; in the first statement you're using numbers, and in the second words
- The operator in the first and second statement is the same, the + operator
- Notice that Ruby did two different things with the data provided, using the same operator. How did ruby know what to do with the data provided?
- The data has a type, and depending on the type, Ruby knows what to do with the data provided when an operator is applied to it.
- In the first statement, the data types of 1 and 5 is Integer, and in the second, the words are all of type String
- Integer and String are only two of several data types in Ruby. We'll cover more a bit later on.
- Talk about arrays
(30 mins)
- string manipulation - count number of words, count number of characters (Twitter 140 chars), ask them to do it and ask what they got
- example of 5 different tweets, tell me which ones are under 140 chars
Writing a script and running it from the console
- Write a simple script, save it, and run it
Ruby I/O
- Basic user input/output
- Give them basic I/O script, get them to use it, break it down after
Logic
- Basic logic
- booleans
- if statements
Methods
- Extend the operator conversation earlier by introducing methods
Loops
- Introduce arrays
- Discuss the basics of loops
- Loop through a simple array
Classes
- Talk about OOP
- Create a very simple class
Ruby console game
- Create a small game using only a few classes
- Blackjack
- Scrabble
- Twitter game - very very basic Twitter
- Password verification game
Jump to Line
Something went wrong with that request. Please try again.