Date post: | 11-Jun-2015 |
Category: |
Business |
Upload: | matthew-turland |
View: | 926 times |
Download: | 0 times |
The Ruby Programming Language
Ryan Farnell
1
History
• 1995
• July 2004 (Ruby on Rails)
2
pure object-orientated
3
What is an object?
4
1. The data an object contains is unique to itself
5
2. Only the object that contains the data can manipulate that data
6
one logical unit with data and functions grouped together
7
demo
8
basic data as objects
9
Value Type of Object
123 Fixnum
“Ruby” String
TRUE TrueClass
10
functions as objects
11
Value Type of Object
function Proc
12
blocks allow for the passing of a function as
a parameter
13
Ways to Use Blocks
• internal iterators
• resource allocation/deallocation
• changing functionality
14
demo
15
Conditionals
16
Ruby supports standard conditionals
17
Ruby also allows post conditions
18
Ruby uses the normal case/when statement as
in other languages
19
Ruby supports standard looping structures
20
internal iterators are often used in place of standard structures
21
demo
22
Classes
23
act as templates for the beginning functionality
of an object
24
class inheritance
25
a class can gain functionality (inherit) from other classes
26
all classes inherit from exactly one class
27
mixins can be used to add extra functionality
28
class gains all the methods in the mixin
29
Mixins
• Have access to all instance variables
• Have access to all private and public methods
30
demo
31
Ruby has some problems
32
Disadvantages• Slow Execution
• Problems with threading
• No specification
33
Virtual Machines• Ruby 1.9 YARV
• JRuby
• IronRuby
• Rubinius
• MacRuby
34
http://www.ruby-lang.org/en/downloads/
35
Books
• Programming Ruby 2nd Edition
• by Dave Thomas, Chad Fowler, and Andy Hunt
• Ruby From Novice to Professional
• Peter Cooper
36
Q & A
37
Metaprogramming
38
code that writes code
39
Ruby has many metaprogramming
hook
40
demo
41