Justin Mui

Justin Mui

Setting Up Your Environment

Slide Duration:

Table of Contents

Section 1: Introduction to Ruby
Setting Up Your Environment

22m 8s

Intro
0:00
Installing Ruby
0:06
Ruby-lan.org
0:07
Three Ways of Installing Ruby
2:26
Compiling Ruby-Source Code
3:02
Third Party Tools
3:28
Other Implementations of Ruby
4:48
Windows Installation
5:21
RubyInstaller.org
5:22
Mac OSX and Linux Installation
6:13
Mac OSX and Linux Installation
6:14
Setting Up Debian/Linux
6:42
Setting Up Debian/Linux
6:43
Installing HomeBrew
6:56
HomeBrew for MAC OSX
6:57
HomeBrew Wiki
9:44
Installing HomeBrew
10:02
Setting Up Mac OSX
11:46
HomeBrew, RVM, OSX-GCC Installer, and Install Ruby 1.9.3
11:47
Ruby Version Manager (RVM)
12:11
Ruby Version Manager (RVM) Overview
12:12
Installing Ruby Version Manager (RVM): http://rvm.io
12:35
Install RVM with Ruby
14:20
Install RVM with Ruby
14:21
Install OSX-GCC-Installer
16:18
Download and Install Package for Your OSX
16:19
Install Ruby 1.9.3
17:28
Install Ruby 1.9.3
17:29
Test It Out!
18:09
rvm-help & ruby-v
18:10
Example: rvm gemset create educator
18:52
Set It As Default!
20:47
rvm Use 1.9.3@educator--default
20:48
Intro to Ruby

22m 20s

Intro
0:00
What is Ruby?
0:06
What is Ruby?
0:07
Ruby Standard Library
0:52
Who Created Ruby?
1:22
Yukihiro Matsumoto
1:23
History
2:45
The Name 'Ruby'
2:46
Ruby v0.95
3:10
Ruby v1.0
3:56
English Language Mailing List Rubytalk
4:08
ruby-forum.com & the Mailing Lists
4:27
Ruby In The West
9:51
Ruby on Rails
10:39
The Pragmatic Programmer's Guide to Ruby
11:30
rubyonrails.org
13:34
Current Ruby
14:42
Ruby 1.8.7, Ruby 1.9.3, and Ruby 2.0
14:43
Why Programmers Enjoy Ruby?
15:40
Why Programmers Enjoy Ruby?
15:41
Ruby Is An Interpreted Language
16:21
Ruby Is An Interpreted Language
16:22
What Is It Used For?
16:50
What Is It Used For?
16:51
Ruby is Object-Oriented
18:17
Example: 5.class
18:18
Example: 0.0.class
18:54
Example: true.class
19:03
Example: nil.class
19:12
Object Class
19:19
BasicObject
19:20
Example
19:52
Superclass
20:50
Fixnum → Integer → Numeric → Object
21:32
Basic Tools for Using Ruby

27m 44s

Intro
0:00
Interactive Ruby
0:08
irb: Interactive Command-Line Environment
0:09
Example
0:49
irb-v
0:50
irb-executes terminal
1:02
1.9.3-p125 > 'hi'
1:09
Live Demonstration
1:31
Why Use Interactive Ruby?
2:21
Why Use Interactive Ruby?
2:22
RDoc
3:05
RDoc
3:06
Ruby Core Documentation
3:32
Ruby Core Documentation: Example
5:30
Ruby Core Documentation: Markup
6:12
Ruby Core Documentation: Headings
7:44
Coding Example: RDoc
9:30
Why Use RDoc?
13:02
Learning Core Ruby Functions
13:03
Generating RDoc
15:31
rdoc-help # usage
15:32
Ruby Interpreter
15:57
ruby -- help
15:58
ruby [switches] [-] program [arguments]
16:16
Example: How to Run a Ruby Script
16:28
Rake
18:38
Rake Overview
18:39
Ruby Core Documentation: Rake
19:46
Coding Example: Rake
23:14
Why Was It Created?
24:30
Why Was It Created?
24:31
Lesson Summary
25:13
Lesson Summary
25:14
IDE/script Editors: MacVIM
26:24
Ruby Specifics

20m 45s

Intro
0:00
Ruby Specifics
0:06
Comments
0:51
Hashtags
1:00
Example
1:23
Multi-Line Comment
2:04
Example
3:10
RDoc Comments
4:02
When do you generate an Rdoc?
4:10
Headings and subheadings
4:24
Examples
4:48
Generating an Rdoc - example
4:50
Common Code Conventions
6:28
For every tab use two spaces indentation
7:38
Never use tabs
7:42
Common Code Conventions (Cont.)
8:18
Camel case
8:20
Snake case
9:18
Identifiers
9:44
Constants begin with CAP letter
10:00
Examples
10:10
Identifiers with Different Scoping
10:26
Global
10:34
Instance Variable
10:40
Class Variable
10:46
Examples
10:56
Reserved Keywords
12:22
Do not use reserved keywords in code
12:25
Parentheses are Sometimes Optional
13:04
Functions do not require parentheses
13:16
When in doubt, use parentheses
13:54
Examples
14:10
Newlines Are Statement Terminators
14:20
Examples
15:10
Continuation with a Period
16:20
Period means continue to next line
16:46
Multiple Statements Allowed on a Single Line
17:38
Try not to use semi-colons
17:58
Code Blocks
18:20
Use code blocks for one liners
18:28
Examples
18:40
Recommended for multiple lines
20:16
Ruby Data Types (Part 1)

29m 37s

Intro
0:00
Overview
0:10
Ruby Data Types
0:10
Numbers
0:16
Strings
0:18
Symbols
0:24
Numbers
0:30
Numeric
0:44
Float
0:50
Complex
0:56
BigDecimal
0:58
Rational
1:00
Integer (most popular) - Fixnum and Bignum
1:06
Fixnum stores 31 bits
1:18
Bignum stores larger bits
1:24
All number objects are instances of Numeric
1:28
Integer Literals
2:28
Represent whole-numbers
2:40
Examples - Different bases
2:42
Binary
3:04
Octal
3:30
Hexadecimal
3:44
Examples
4:06
Floating Point Literals
4:45
Examples
4:58
e-value can be capital or lowercase
5:30
Example
5:44
Strings
6:16
Mutable objects
6:18
Used for inserting and deleting text, searching, and replacing
6:26
String Rdoc
6:46
Definition
7:00
String Literals
8:20
Single-Quoted
8:28
Double-Quoted (most used)
8:50
Example
9:32
Escape Sequences
11:10
Newline
11:16
Tab
11:22
Double quote
11:28
Blackslash
11:36
Interpolation
11:50
Sprintf
13:48
Unicode Escaping
14:38
Example
15:50
Delimiters
16:18
Here Documents
17:18
Example
17:25
String Operators
19:58
Concatenation
20:03
Appending
20:40
String Equality
21:04
Example
21:24
Substrings
22:00
Range object (inclusive)
22:22
String Encoding
24:52
Differences between Ruby 1.8 and 1.9
24:56
Symbols
26:02
Definitions
26:04
Examples
26:46
When to use symbols
26:54
Symbols and Strings
27:42
Symbols Rdoc
28:22
Ruby Gems

25m 50s

Intro
0:00
RubyGems
0:08
What are RubyGems?
0:24
RubyGems.org
0:44
How RubyGems are used
2:06
Java's jar utility
2:50
Unix/Linux's tar utility
3:06
What is a Gem?
3:16
Definition of Gem
3:20
Version
3:34
Date
3:44
Author
3:50
Description
5:58
What Are the Uses?
4:18
Uses for Gems
4:22
Installation
5:06
How to install RubyGems
5:30
Updating to the Latest Ruby Gems
5:54
Testing
6:22
Example
6:34
Installing Rake
7:24
Example
7:46
Verifying
9:22
Example
9:56
Structure
10:56
gem.gemspec
11:30
Specification
13:40
What is in the gem?
13:42
Who made it?
13:50
Update gem version
13:58
Example
14:10
Create Our First Gem
17:20
Steps involved
17:28
RubyGems Guides
17:36
Example
20:02
Steps Review
18:56
Create Our First Gem (Cont.)
23:08
Building the gem
19:38
Example
20:00
Installing the gem
22:32
Run it
22:52
Publish it
23:04
Get Some Gems!
25:06
rake
25:14
rails
25:19
fastercsv
25:25
koala
25:37
Ruby Data Types (Part 2)

40m 24s

Intro
0:00
Ruby Data Types
0:15
Boolean
0:21
Arrays
0:27
Hashes
0:33
Range
0:37
Boolean Types
0:42
TrueClass
0:56
FalseClass
1:12
NilClass
1:18
TrueClass Examples
2:48
FalseClass Examples
3:22
Arrays
4:16
Ordered collection of objects
4:22
Can hold different objects
4:32
Starts at index 0
4:50
Array of Strings
5:50
Example
5:52
Arrays (Cont.)
6:20
Can be created using literals
6:22
Can be created using constructors
6:54
Position and indexed value
8:04
Negative Indexed Values
8:56
Shift and Unshift
10:18
Push and Pop
11:38
.delete method
12:38
Addition and Subtraction
13:32
Union and Intersection
14:48
Insert
15:52
Iteration
16:52
Arrays Rdoc
17:48
Hashes
22:08
Maps and Associative Arrays
22:44
Created using the constructor
22:56
Created using a hash literal
24:02
Stored in a hash table
25:26
Example
25:50
Accessing Key-Values
27:46
Deletion
29:48
Iteration
31:04
Hashes Rdoc
32:04
Ranges
36:40
Two dots are inclusive
36:57
Three dots are exclusive
37:16
Example
37:50
Ranges Rdoc
38:24
Objects

1h 5m 46s

Intro
0:00
Objects
0:10
Object References
1:36
Ruby Core
2:16
Example
4:30
Creating New Objects
6:00
New Method
6:08
Initialize Method
6:31
Example
7:18
Garbage Collection
9:54
Global values always reachable
10:25
Object Identity
11:08
Every object has an object identifier
11:20
Object identifier is constant and unique
11:30
Example
11:54
Object Class
12:58
Class method
13:10
Superclass method
13:28
Object Testing
14:46
is_a?
15:49
respond_to?
16:26
String and Regexp
18:10
Comparing two object instances
20:06
Example
23:30
Object Equality
25:48
Comparing objects
25:54
equal?
25:58
Popular way to test for equality
27:16
Opposite way to test for equality
27:25
Arrays
28:30
Hash
29:42
Case equality operator
30:47
Class tests
31:16
Range tests
31:48
Symbol tests
32:32
Object Conversion
33:14
Explicit conversion
33:54
Implicit conversion
35:00
Example
36:12
Object Conversion: Kernel Module
38:22
Array
38:38
Float
39:26
Integer
39:58
String
40:10
Example
40:34
Object Conversion: Coerce
42:00
Used for mixed type numeric operations
42:08
Example
43:40
Object Conversion: Boolean
47:42
Every object has a boolean value
47:44
Example
48:54
Object Copying
50:52
dup
50:58
clone
51:03
Example
51:42
Object Freezing
57:36
Object Marshaling
58:38
Save state
59:04
Load state
59:27
Example
59:32
Tainted Objects
1:01:50
taint
1:02:08
farm field
1:02:12
Untrusted Objects
1:04:06
trust
1:04:24
untrust
1:04:34
untrusted?
1:04:42
Loops

38m 54s

Intro
0:00
Loops
0:12
while and until
0:48
for and in
0:54
iterators
1:04
enumerable in objects
1:06
While-loop
1:14
Will keep going is condition is true
1:18
Until-loop
2:58
Will keep going until condition becomes true
3:06
Single Expression Loops
4:20
Compact form
4:30
Expressed as a modifier
4:42
Do-While Loop
5:52
Executes body first
6:06
Do-Until Loop
7:54
Similar to do-while loop
7:58
Using Break Inside Loops
8:54
break
8:58
For-In Loop
11:56
for-loop
12:06
var
12:34
collection
12:54
body
13:00
Examples
13:08
Examples (Cont.)
15:54
Nested loops
16:40
Numeric Iterators
18:32
upto
18:40
downto
18:42
times
18:48
Examples
20:28
External Iterators
21:00
Enumerator class
21:04
Rdoc
21:16
Enumerables in Objects
24:35
Enumerable is a mix-in
24:41
RDoc
25:24
Commonly Used Enumerables in Objects
27:01
Array
27:19
Hash
27:51
Range
28:47
Examples
29:29
Enumerables in Objects (Cont.)
31:13
File Processing
31:15
Example
31:45
Enumerables in Objects (Cont.)
33:07
collect
33:23
select
34:11
reject
34:59
inject
35:29
Strings

28m 30s

Intro
0:00
Strings
0:08
Why do you want to get familiar with strings?
1:00
String Creation
1:16
new
1:28
empty?
1:50
length or size
2:10
Example
3:12
String Manipulation
4:40
slice
4:56
square brackets [ ]
5:02
token
5:40
[fixnum]
6:52
offset and length
8:40
chaining
12:42
String Insertion
12:56
insert
12:58
positive or negative index
13:46
String Updates
15:24
[token]
15:36
Examples
16:40
chop or chop!
17:54
chomp!
18:56
gsub
20:28
String Deletion
21:38
delete
21:38
String Reversal
22:46
reverse
22:52
String Manipulation
23:16
split(pattern=$, limit)
23:22
pattern
24:10
limit
24:15
upcase or upcase!
25:28
downcase or downcase!
26:02
swapcase
26:24
Incrementing Strings
27:26
next or next!
27:32
Check Out the Other Lessons
28:00
Ruby Data Types Part 1
28:12
Regular Expressions
28:18
Regular Expressions

33m 27s

Intro
0:00
Regular Expressions
0:10
How to create a regular expression
0:48
What goes inside
1:36
Metacharacters
3:10
Bracket expressions
3:14
Quantifiers
3:18
Anchors
3:20
Metacharacters
3:30
word and non-word characters
4:04
digit and non-digit characters
4:44
hexdigit and non-hexdigit characters
4:56
whitespace and non-whitespace characters
5:08
Examples
5:24
POSIX Bracket Expressions
7:48
Non-POSIX Bracket Expressions
9:48
Bracket Expression Examples
10:58
Quantifiers
12:34
Examples
13:30
Character Properties
17:24
Similar to POSIX bracket classes
18:22
More Character Properties
18:48
Examples
19:32
Anchors
20:08
Examples
21:14
Regular Expression Matching: Regexp Object
22:40
match
22:51
Regular Expression Matching: String Object
24:14
match
24:26
Regular Expression Modifier Characters
25:14
pat
25:38
Example
26:42
Regular Expression Modifier Objects
27:14
Example
28:38
Regexp Rdoc
30:40
Arrays

14m 35s

Intro
0:00
Arrays
0:12
Creating an Array with a Block
0:50
Alternative Ways to Create an Array
3:52
Checking the Class
5:14
Iterate through the array
5:26
Call the class method
5:28
Array Shortcuts
6:38
at(index)
6:44
delete_at(index)
7:28
first(n)
8:28
last(n)
9:28
Removing Duplicates
9:58
uniq or uniq!
10:04
Sorting the Array
10:48
sort or sort!
10:54
Getting the Index
11:35
index
11:56
rindex
12:38
Multidimensional Arrays
12:56
flatten
13:33
Check Out the Earlier Lesson
14:16
Ruby Data Types Part 2
14:26
Hashes

27m 48s

Intro
0:00
Hashes
0:12
Creating Hashes
1:18
Setting a Default Value
2:24
Accessing Hashes
4:16
Accessible by keys or by values
4:28
Keys must be unique
4:36
Creating Hashes
5:16
Comma-separated list
5:42
Hash rocket
8:28
Examples
10:16
Iterating Keys and Values
11:43
each_key
12:04
each_value
14:04
Merging Hashes
16:10
merge(other_hash)
16:20
Sorting Hashes
18:46
Replacing Hashes
20:57
replace(other_hash)
21:18
Converting Hashes to Other Classes
22:04
to_a
22:22
to_s
23:22
Example
24:34
Check Out the Earlier Lesson
27:22
Ruby Data Types Part 2
27:32
Math Operations, Part 1

28m 47s

Intro
0:00
Math Objects
0:12
Numeric
0:26
Integer
0:38
Float
1:02
Fixnum
1:14
Bignum
1:56
Rational
2:04
Math
2:24
Math Operations
2:36
Example
3:14
div(numeric)
4:54
divmod(numeric)
6:30
modulo(numeric)
7:23
quo(numeric)
8:18
remainder(numeric)
9:35
Operation Precedence 1 of 3
10:35
Operation Precedence 2 of 3
13:18
Operation Precedence 3 of 3
14:28
Abbreviated Math Operations
14:54
Move the operator in front of the equal sign
15:52
Numbers
16:36
Numeric Class
17:06
Numeric Methods
18:41
ceil
18:52
floor
19:32
round
19:50
Example with Numbers
20:20
Numeric Methods (Cont.)
22:20
truncate
22:28
num.step(limit, step)
23:02
Numeric Rdoc
25:26
Math Operations, Part 2

28m 51s

Intro
0:00
Math Operations
0:12
Math Module
0:24
Rational Numbers
0:44
Complex Numbers
0:52
Prime Numbers
0:58
Matrices
1:06
Math Module
1:12
PI and E
1:32
Math Module Methods
2:47
atan2(x,y)
2:56
cos(x)
3:14
exp(x)
3:44
Examples
4:38
log(x)
5:44
log(num, base)
6:34
log10(x)
7:04
sin(x)
7:34
sqrt(x)
7:52
tan(x)
8:06
Math Functions: Part 1 of 3
8:12
Math Functions: Part 2 of 3
9:32
Math Functions: Part 3 of 3
10:19
Math Module Rdoc
11:25
Rational Numbers
13:23
How to use
14:06
Example
15:02
Mathematical Ruby Scripts (Mathn)
16:25
Example
17:28
Complex Numbers
18:26
polar
18:56
rect
19:10
Complex Number Examples
19:18
Prime Numbers
20:14
each(ubound=nil)
20:44
prime?
21:22
Example
21:58
Matrices
23:15
build(row_size, column_size=row_size)
23:44
Example
24:44
Matrix Rdoc
24:58
Dates and Times

26m 1s

Intro
0:00
Dates and Times
0:12
Time Class
0:38
Methods of the Time Class
1:43
now
1:44
at(time)
2:10
Epoch & Unix Timestamp Conversion Tools
3:19
Components of a Time
5:07
Convert Time to an Array
5:54
to_a
6:08
Creating a New Time
6:48
Time.local
7:08
Year is required
7:22
Time.utc
8:12
What should be specified
9:30
More Methods of the Time Class
10:16
strftime(string)
11:26
RDoc
12:50
Date Library
16:46
Initializing a New Date
17:08
Parsing Dates
18:28
parse(string)
18:42
Today's Date
19:19
Date.today
19:22
Tomorrow's Date
20:22
Next
20:28
Next week
21:22
Count Down
21:26
Count Up
22:37
Components of a Date
23:20
Converting to Datetime
23:48
to_datetime
24:00
Initializing a Datetime
24:24
Converting to Time
25:23
self.to_time
25:32
Methods: Part 1

31m 24s

Intro
0:00
What is a Method?
0:12
Basic Method
0:58
Return Value
4:37
return
4:46
Factorial Example
6:18
Example
8:46
Return Two Values
10:06
Set the return keyword
10:14
Collected and returned as an array
10:28
Undefining Methods
11:22
undef method_to_undefine
11:44
Example
12:32
Method Names
13:02
Begin with lowercase letter
13:16
Separate longer words with underscores
13:26
Can end with equal sign, question mark, or exclamation point
14:03
Equal sign
14:26
Method Names with Question Mark
14:44
empty?
15:24
Method Names with Exclamation Point
16:01
mutators
16:12
! means use with caution
16:46
Method Aliases
18:05
alias new_method existing_method
18:42
Operator Methods
20:00
Operators
20:02
Array Operators
20:10
Unary Operators
20:32
Binary Operators
20:40
Example
21:28
Methods and Parentheses
25:00
Optional in most cases
25:20
Required in other cases
27:13
Methods and Blocks
27:54
Associated with blocks
28:18
block_given?
28:26
yield
28:36
Example
29:24
Methods: Part 2

20m 11s

Intro
0:00
Methods with the Unary Ampersand Operator
0:14
&
0:34
Block to a Proc
0:56
Example
2:02
Proc object
3:58
Example
5:04
Methods with Default Values
5:54
Example
7:12
Methods with variable-Length Arguments
8:05
How to create it
8:36
Example
11:06
Using Hashes with Arguments
13:02
Multiple arguments
13:08
Solution
13:30
Example
14:56
Rdoc
18:12
Classes: Part I

26m 51s

Intro
0:00
Classes
0:10
Definition of a class
0:14
Class represents a container
0:32
Can be reused
0:46
Creating our First Class
1:00
Keyword class will create new class
1:06
Name must begin with capital letter
1:30
Instantiating Our First Class
2:46
New will create a new instance of class
2:58
Initializing Values
3:58
Definition of def
4:14
Instance method
5:08
Example
7:02
Defining the to_s Method
8:24
Creating a string representation class
8:34
Example
10:54
Self in the Class
12:16
Definition of self
12:26
Example
13:54
Accessor Methods
15:52
getter methods
16:22
Example
17:00
Setter Methods
18:00
Mutator methods
18:02
Example
19:46
Automating Getter and Setter Methods
21:10
Defined in the module class
21:30
attr_reader
21:54
attr_writer
22:48
attr creates getter and setter methods
23:50
Example
24:28
Notes on Ruby's Accessor Methods
25:32
Classes: Part II

26m 42s

Intro
0:00
Defining Operators
0:10
You can define arithmetic operators
0:32
Unary Operators
0:46
Let's define operators in our class!
0:56
Example
2:52
Class Methods
6:24
Examples
6:56
Opening Up the Class
9:38
Adds an additional method
9:54
Examples
11:04
Array and Hash Access Method
15:40
Use square brackets
16:02
Define your own has access method
16:08
Example
16:56
Enumerating The Values
18:40
Define the each iterator
18:40
Testing for Equality
19:36
Class Triplex
19:50
Examples
20:54
Constants
25:00
Usually defined at the top of class
25:24
Classes: Part III

53m 36s

Intro
0:00
Class Variables
0:14
Example
2:16
Ruby Glass Jar Example
8:50
Class Instance Variables
10:20
Instance variables of class objects
10:46
Advantage of class instance variables
11:18
Examples
11:30
Method Visibility
16:16
Three types of method visibility
16:26
Public methods
17:34
Private methods
17:38
Protected methods
18:04
Invoking Method Visibility
19:21
Public , Protected, and Private Visibility
19:22
Invoking Method Visibility With Arguments
21:39
Example: Invoking Method Visibility
22:12
Class Visibility
23:31
Instance and Class Variables are Private
23:32
Constants are Public
24:00
Makes Existing Class Methods Private
24:27
Makes Existing Class Methods Public
25:08
Example: Class Visibility and class GlassJar
25:43
Subclassing
27:08
Subclassing: Subclass and Superclass
27:09
Example: Subclassing
29:43
Inheritance
30:05
Inheritance
30:06
Example: Inheritance
31:25
Subclassing and Inheritance
31:34
Descendants
31:41
Ancestors
31:56
More On Descendants and Ancestors
32:08
Extending a Class
33:27
Extending a Class
33:28
Coding Example: Extending a Class
34:24
Overriding a Method
36:41
Overriding a Method
36:42
Coding Example: Overriding a Method
37:18
Modifying Methods with Chaining
38:52
Modifying Methods with Chaining
38:53
Super
39:25
Coding Example: Modifying Methods with Chaining
39:51
The Singleton Pattern
44:52
Introduction to The Singleton Pattern
44:53
Setting Up Singleton
45:28
The Instance Method
45:58
Rdoc for Singleton: Usage
46:23
Rdoc for Singleton: Implementation
47:45
Coding Example: Singleton
49:38
Modules

24m 19s

Intro
0:00
Modules
0:04
What is Modules?
0:05
Modules Examples
0:40
Modules: Mix-Ins
3:31
What is a Mix-in?
3:32
Modules: Namespace
4:07
What is a Namespace?
4:08
Why Use a Namespace?
5:13
Example of a Namespace Module
5:59
Example of Mixing in The Module Into the Global Scope
6:00
Modules: Creation
7:04
How to Create a New Module?
7:05
Modules: Usage
8:19
How to Use It?
8:20
class Poker & class Bridge
9:13
Creating Our Module as a Mix-In
9:41
Example of a Module Using Instance Methods
9:42
Coding Example
10:20
Creating Our Module as a Namespace
12:11
Implement Class Methods for the Module
12:12
Coding Example
14:56
Loading Our Module
19:46
Loading Our Module Overview
19:47
Require & Load
20:15
Coding Example: Loading Module
20:48
Lesson Summary
23:36
Loading...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to Ruby
Bookmark & Share Embed

Share this knowledge with your friends!

Copy & Paste this embed code into your website’s HTML

Please ensure that your website editor is in text mode when you paste the code.
(In Wordpress, the mode button is on the top right corner.)
  ×
  • - Allow users to view the embedded video in full-size.
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Services

Lecture Comments (10)

1 answer

Last reply by: Professor Mui
Wed Mar 12, 2014 12:28 AM

Post by Abdallah Alqassabi on March 7, 2014


I am new to programming, but there is something that i did not understand at the very beginning for sitting up the program. I did not get the part one you go to brew and copy some stuff and you past them somewhere that i don't know, as well as the RVM and stuff. Could you please explain what are they ? and what are the things specifically that i need to download. I am using Mac OS X. Please help !

0 answers

Post by Professor Mui on August 14, 2013

Yes, Ruby 2.0.0 is the latest version.  You can use that one and still continue through the lessons!

0 answers

Post by Kelvin Tjia on August 13, 2013

please keep in mind that this was recorded in the past and in the future there may have been changes.

Do i download the Ruby 1.9.3? The top one on the list is now Ruby 2.0.0.

I am new to programming.

Thanks!

1 answer

Last reply by: Professor Mui
Tue Jun 11, 2013 10:39 AM

Post by Caleb Lear on June 6, 2013

I wonder if you might include the links in the Quick Notes so we can just copy and paste them?

1 answer

Last reply by: Professor Mui
Wed Mar 6, 2013 9:37 PM

Post by Jonathan Aguero on March 6, 2013

how do I become the user/owner for ruby doesn't let me I have a hp windows 8 laptop what can I use as the code as the user

1 answer

Last reply by: Professor Mui
Wed Feb 13, 2013 1:15 AM

Post by marvin evins on February 12, 2013

how do you get to your bash profile on 14:55? Is it cd/.bash profile?

Setting Up Your Environment

  • This lesson gives you an introduction to ruby through its history starting from its creation and its spreading from the eastern world to the western world.
  • Ruby is a dynamic and expression programming language that is elegant and flexible
  • Ruby was created by Yukihero Matsumoto. He wanted to design a programming that that would "make programmers happy."
  • You can follow
  • Ruby was popular in Japan but grew popular in the west around 2000 when the first English book "Programming Ruby" was printed
  • The book can be seen online at: http://ruby-doc.org/docs/ProgrammingRuby/
  • The first English mailing list Ruby-talk and other Ruby mailing lists can be found at: http://www.ruby-forum.com/
  • You can also subscribe to Ruby-talk through email at: http://www.ruby-lang.org/en/community/mailing-lists/
  • Ruby popularity skyrocketed with interest in Ruby on Rails (http://rubyonrails.org).
  • Ruby is an interpreted language, scripting language, and also suitable for procedural and functional programming.
  • Every value in ruby is an object.

Setting Up Your Environment

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Installing Ruby 0:06
    • Ruby-lan.org
    • Three Ways of Installing Ruby
    • Compiling Ruby-Source Code
    • Third Party Tools
    • Other Implementations of Ruby
  • Windows Installation 5:21
    • RubyInstaller.org
  • Mac OSX and Linux Installation 6:13
    • Mac OSX and Linux Installation
  • Setting Up Debian/Linux 6:42
    • Setting Up Debian/Linux
  • Installing HomeBrew 6:56
    • HomeBrew for MAC OSX
    • HomeBrew Wiki
    • Installing HomeBrew
  • Setting Up Mac OSX 11:46
    • HomeBrew, RVM, OSX-GCC Installer, and Install Ruby 1.9.3
  • Ruby Version Manager (RVM) 12:11
    • Ruby Version Manager (RVM) Overview
    • Installing Ruby Version Manager (RVM): http://rvm.io
  • Install RVM with Ruby 14:20
    • Install RVM with Ruby
  • Install OSX-GCC-Installer 16:18
    • Download and Install Package for Your OSX
  • Install Ruby 1.9.3 17:28
    • Install Ruby 1.9.3
  • Test It Out! 18:09
    • rvm-help & ruby-v
    • Example: rvm gemset create educator
  • Set It As Default! 20:47
    • rvm Use 1.9.3@educator--default

Transcription: Setting Up Your Environment

Welcome back to educator.com. Today's lesson is on setting up your environment.0000

The goal of this lesson is to get your environment set up so you are using the same Ruby version as us, and you have everything in sync, so you have the same tools I'm using.0006

The first thing we are going to look at is ruby-lang.org.0025

This has the core Ruby code--source code--and we are going to be using 1.9.3 for all of our lessons.0032

If you are on a Mac, you might see 1.8.7 set up by default, but you should go through the steps in this lesson to get you set up with 1.9.3 so you don't see any issues as you are developing.0049

First, let's go to that website, ruby-lang.org, and check it out.0066

If you go here, at ruby-lang.org, you will notice that it has a lot of documentation information, about it.0071

It will give you a little gist of what Ruby is, and it will show you some code for a class.0085

What they do here, is they give you a lot of versions... from latest to oldest.0096

So you will see that it says "1.9.3-p27 is released."0101

That's the latest one. And you can go here and see the change log, and see what bugs have been fixed.0107

Go ahead and click the change log; you will see that they give you a whole list of things that have been fixed for this version.0119

You can go ahead and check it out if you want, but I think mostly you just want to get the most stable one, so I'll show you how to do that.0126

The main thing here...you see all this news...the main thing here is this "Download Ruby" button.0134

So, you click "Download Ruby," and it will tell you that the stable version is 1.9.3, and it will tell you three ways of installing Ruby.0144

Going through these ways: one is compiling it from source, another is using a third-party tool to install Ruby--and we are going to go through each of these-- and using a package management system.0156

One third-party uses RVM.0174

We're going to go over that. So, first, compiling Ruby by source:0179

You can just download this link here; that will give you the latest one.0187

It's tar and gzip. So, you know how to install source...0191

Go ahead and download and compile it.0195

But we are going to go through setting up RVM, so you might want to take a look at that before you just build from source.0201

That is the next one: they say here, "Use a third-party tool."0208

This RVM is very popular. It's called Ruby Version Manager, and it makes it so installing Ruby is easy.0211

Plus, developing it is easy, because I can use multiple versions of Ruby as I'm developing.0222

It is available for Mac OS, Linux, or any UNIX operating system.0226

Windows does have a version, pik, that does a similar thing.0232

It's very easy to install: use this curl command...0237

And then there is RubyInstaller: that is for Windows, to install the Ruby version on Windows.0244

And then they have packages: Linux--you can use "apt-get" to install it, and also there is a package called pacman for Arch Linux system;0253

Mac OS X--you can do "brew install ruby"--0269

Brew is also another package--0274

Then if you are looking at Solaris or OpenIndiana, you can use this "pkg install runtime/ruby-18".0278

There are also other implementations of Ruby.0288

We are not going to get into those, but it's good to know that you have them there.0291

You have JRuby for a Java Virtual Machine, MacRuby to run Mac OS code, IronRuby for .NET.0298

So, that is ruby-lang.org for you.0310

Mostly, you build it from source; that's what you use for it; but we are going to go a different route.0314

Let's go ahead and click RubyInstaller, for you Windows folks; they make it really easy for you.0321

I'm at rubyinstaller.org, and they have a 1.8.7 version and a 1.9.3. You are going to get the 1.9.3 version.0333

Click on the "Download" button--just choose this top one--0338

It's executable. You download it; you get an executor; you double-click; you install it.0343

It will get you all set up with Ruby.0348

You also have a lot of information here about documentation for it.0353

You can go to this "help" button, and it has a whole wiki of information to help you set it up, as well, if you have issues.0359

Double-click, you're set up, ready to go.0368

And Mac OS X and Linux installation--we already saw it--0373

You go to ruby-lang; you can install it through source, install it through the package management system.0379

But we are going to do it differently. We are going to install it using a combination of Brew and RVM.0385

So, this is my recommended route; we are going to use Brew and RVM to do that.0392

I'm setting it up with a Debian Linux.0402

You can just use "sudo apt-get install ruby 1.9.3", and it will get your version set up for that.0408

And so, we are going to deep-dive right into doing it with Homebrew.0413

Now we have it for a Debian; we have it set up for Windows.0423

Now we are going to structure it for the Mac OS X. A lot of my lessons will be in the Mac OS platform,0428

So let's see if we can get you to mimic the same behavior on your setup right now.0436

The first thing that we want to do is install Homebrew on your Mac machine.0441

Just go to this link over here, and what we are first going to do is install Brew--0447

It's a one-line command, and then we want to run Brew Update, and then you want to install a library.0456

Type "brew install libksba"0465

Actually, let me remind you that this library here--0468

You probably want to take notes on this, too, but--0474

This one is required because you are installing Ruby 1.9.3.0478

This is required...for Ruby 1.9.30483

What Brew Update is going to do is update Brew and make sure it's on the latest system file.0495

So, you want to run that next, after you install Brew.0502

Let's go ahead and look at the browser to see that.0507

So I'm going to go up here, and I'm just going...let me zoom it in a little bit deeper...0513

But Homebrew is a package management system on OS X.0519

They make it really easy to install things.0524

If I want to install wget, I just use Brew install wget.0529

I don't have to worry about getting it from the source--it's going to handle that for me.0532

It installs these packages in their own directories, links them up for me, does a lot of the rough work.0535

You will notice there is a lot of information documentation to help you get along, but what I want you to do is just go way to the bottom of this page.0548

And look at the main "Install Ruby"; that is the main one we're talking about doing.0558

So, you have this command here...0563

Run that, and you will get Homebrew set up on your machine.0568

Because it does say Ruby on it, there are further instructions if you don't have Ruby already set up to do it.0574

Go to Homebrew wiki, and it will show you some other methods to install it.0584

Because, most likely, you are already on 1.8.7, but we're upgrading to 1.9.3.0596

So what you will do is...because, when I run ruby -e, you will see...I'm already on 1.9.3.0601

But what I did is first, some hints for just installing Brew, if I just run Brew, you can already see your setup.0615

You have some examples of usage like this, when you run the brew command.0627

I'm not sure if there is a version. Let me run --brew...there is a version. So I'm running 0.9.3.0631

But, when I install it, I copied that command from that page, I paste it here, and I just press Return.0635

And it's going to fetch this Homebrew and it's going to execute it. And that is going to install it for you.0642

But since it's already set up, I'm not going to do that, but I'm just commenting about that.0651

That's it. Just run that command, press Return, and it will install it for you.0656

If I even ran it now, it's going to start doing some things, downloading it, but I'm going to cancel that, but that's it.0661

You will notice you have your "Install Homebrew": you are going to click here; it gives you some information; install it...0672

But really, that one-liner is all you need.0686

And remember, after you get that Homebrew installed, run Brew Update and Brew Install...this libksba library.0690

That is important so we can move you up to 1.9.3.0702

OK, so we talked about Homebrew.0707

Next on our list, we need to install RVM.0712

And then we are going to look at OS X GCC installer,0717

and then installing Ruby 1.9.3.0723

There is quite a little bit of things we have to do to get you up to that version.0726

Ruby Version Manager--that is what RVM is. That is the acronym.0732

This is a command-line tool that allows you to install, manage, and work with multiple Ruby environments.0738

Ruby environments/Ruby versions. It's a very nice tool.0746

It allows you to...let you be able to run Ruby 1.8 and Ruby 1.9 concurrently.0750

So, let's go ahead and look at the page. We're going to go to rvm.io.0755

I already have the browser set up. On the page, they have this...there you go. I lost my browser for a moment.0767

This is Ruby Version Manager. You get a nice splash page.0780

As you go down, you will notice "visit the installation documentation."0784

They have screencasts, so you can look at screencasts and see videos.0790

And, they have some things about Rails, too.0794

First, I want you to just look at the introduction.0799

They will give you a little spiel about what it does, and then what we want to do is just install it. That's the main thing.0804

They have a lot of great documentation here, but let's just get right into installing this.0812

Let's click...when you click the installation document, you will see "Installing RVM,"0818

and they give you a quickguide. Again, it's just like Brew; it's just a one-liner.0828

You have a curl command; you can just copy that, paste that in your terminal, and get you set up, on your way0832

Again, here is that command, right there. If you just run that in your terminal, press Return, let it install...it will take a little bit of time...0864

After that is set up, you have to update your .bash profile.0870

So in your relative directory--.bash profile-- you need to include this line--it's all one line.0875

And what this line will do is make sure that RVM is loaded when you open your terminal.0883

It loads RVM, which is very important for us.0896

If...I have my terminal here, all I have to do is run this command, press Return--it's going to install RVM.0903

Again, it's already installed on my machine, but if I did RVM --version,0912

You will notice it's RVM 1.5.8.0921

So after you do that, let's go to my .bash profile.0928

I've already added that line, so if I go to relative path, and just do run-profile, and I press Return--this is where you would paste that command from that slide-- and all this does it to get RVM set up on your machine.0934

It runs source, so make sure it's loaded up on that terminal.0955

Then, you can go ahead and run RVM. You will see a lot of usage information there, and a lot of different things you can do with RVM here.0960

Now that we have RVM set up, we have Brew installed, and now we need to set up this OS X GCC installer.0980

This, again, is something we need for Ruby 1.9.3.0990

So you need to go to this link, and you just download the file there. Double-click; install it to your Mac OS machine.0994

And it's going to be set up, installing.1004

I go to the link here...you want to choose the latest one...10.7-v2.1009

But you can also see, that's for OS X versions 10.7 and up1015

If you are going to download to OS X 10.6, then choose the one right below that.1023

Download it to your machine, double-click, and it will install it from there.1030

That will install the OS X GCC installer.1036

So you are almost complete--we almost have it set up. We just need to get 193 going now.1043

And now it's very easy. All you have to do is run this Ruby...install...1.9.3.1049

And that should get it going--very easy. In your terminal, RVM install 1.9.3,1057

Return, let it load up. If you are on an older Mac OS version--if you are on Snow Leopard--1063

You might have to, if you have any issues, do RVM reinstall 1.9.3, with GCC Clang.1068

That should resolve any issues; there are some common bugs with Snow Leopard, so just run that and try it out. After that, just run ruby-re;1080

If you see that Ruby 1.9.3, you're set.1091

You can also run RVM-help; they have a lot of usage information to see commands you are going to do with RVM, because what they do in RVM is you run RVM, and then you can run options.1096

In these options, you can run different things.1112

The next thing we're going to do after this is create a Gemset.1118

That is one of the options there.1122

You can actually change the Ruby version, too.1127

OK. Now we are set up. We have RVM going.1131

The next thing I want to do is set up this Gemset.1136

What this does is to encapsulate all the different Gems I have-- all my different plugins-into one area.1140

This area--we're going to call it Educator. Let me show you that, too, now.1150

RVM, Gemset, Create, Educator.1155

You see, when I press Return, it says "Educator Gemset Created."1161

And later on, I can just use "RVM, Use Gemset, Educator," and it will go back to it.1167

Wait...it looks like something...I think I have to use "RVM, Gemset, Educator,"1174

Yes, "RVM, Gemset, Use Educator."1190

But what this does is, if I do Gem List,1195

There is a list of Gems here, and when I create a new Gemset, it will have a different list.1200

So, let's do "RVM, Gemset, Create, Educator 2," and I'll do "RVM, Gemset, Use Educator 2,"1207

You will notice that if I do Gem List, I will have a different set from if I do "RVM, Gemset, Use Educator 1."1218

They are both different containers with their own gems in them.1226

OK, run that, test it out--run RVM, the Ruby version, and you should have your Ruby set up, your RVM set up; you have your Ruby 1.9.3;1235

You have a Gemset created, as well; and all you do is set that as default.1245

When RVM...Use 1.9.3 at Educator,1252

So, what this does is it sets up your Gemset...1257

It sets up Ruby 1.9.3, and then it defaults it--makes this your default environment whenever you are developing.1268

The reason those are...it's --flak.1290

And there you go! You have RVM set up, now you have your environment set up, and now we can get to some cool things in Ruby--1294

Start doing some development...we have the latest Ruby version going...1300

You're getting happy, learning about Ruby, and you are getting really ingrained into it, so it's nice.1306

That is the end of this lesson, and I hope you enjoyed it and will go on with me into the next lesson.1314

There we will go on to deeper functionality in Ruby and start getting closer to doing some code.1323

Educator®

Please sign in to participate in this lecture discussion.

Resetting Your Password?
OR

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Membership Overview

  • Available 24/7. Unlimited Access to Our Entire Library.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lecture slides for taking notes.
  • Track your course viewing progress.
  • Accessible anytime, anywhere with our Android and iOS apps.