Foss Ruby Software Development
Foss Ruby Software Development
with Ruby
by Teo Choong Ping
#!/usr/bin/ruby
puts "Hello World"
Ruby background and history
● Hash
● IO
● Subroutine
● OOP
Ruby in 10 minutes!
Loop
i=0
while i < 3
print i, "weee \n" Output:
i += 1 weee
end weee
weee
for n in 0...3
print n, "weee \n"
end
Ruby in 10 minutes!
Array
# array = Array.new()
# array = []
array.push('one')
array.push('two') Output:
array[2] = 'three' one
two
(0..array.length()).each do three
|n|
print "#{n} \n "
end
Output:
name => sey
e-mail => seymores...
language => ruby
sey
Ruby in 10 minutes!
IO
file = File.new('/etc/resolv.conf', 'r')
arrayLines = file.readlines()
i=0
arrayLines.each{|line| printf("Element %3d: %s\n", i, line.chomp); i+=1}
file.each{|line| printf("Line %3d: %s\n", i, line.chomp); i+=1}
file.close()
say_hello_world(“sey”)
Output:
Hello World, sey
Ruby in 10 minutes!
OOP
class Customer < Person
attr_accessor :name, :occupation
● bzzz.rubyforge.org
The Future of Ruby...
● Web 2.0
● RAD GUI Database Application
● Framework development
● Distributed application
How to get started.
shitmores.blogspot.com