Upload
emad-elsaid
View
354
Download
4
Embed Size (px)
DESCRIPTION
Code of the world we emplemented while the speak https://gist.github.com/blazeeboy/5301160
Citation preview
Ruby Basics
Ruby syntax
Practice
Solve last assignment
New assignment
Questions
Irb
Ruby
SublimeText 2
http://www.ruby-doc.org
Print hello world
Create world variables
Write them in files
def name(param1,param2,param3)
…code here…
end
Create a function that print world data
Name : string
Version : numeric
Time : time
Continents : array
Creatures : hash
Try double quoted strings, it is fun
Try using symbols
Use methods to capitalize keys
Check classes for existing variables
Add methods to objects
Add methods to existing classes
Create classes(world, human, animal, insect)
Initialize
attr_accessor
class Name
…code goes here…
end
If … end
If … else
If … elsif … else … end
Check for day/night in world
Unless
Case … when … else … end
Check for meal times in world
While … end
Until … end
For x in arr … end
Feed humans with animals
Block_given?
Yield
Block
Block with parameter
Burry dead humans
Dir
Pwd
Glob
Mkdir
Exists?
Open
Close
Enteries
each
• File
• Open
• Close
• Delete
• Readlines
• Rewind
• write
New libraries, modules …etc
Rails is a gem
Rails plugins are gems
Gem install rails
Gem update --system
Gem update
Gem install rails
http://rubygems.org/
Solve
http://projecteuler.net/problem=3
Read
http://guides.rubyonrails.org/getting_started.ht
ml
Practice (Plus)
http://railsforzombies.org/
The prime factors of 13195 are 5, 7, 13 and
29.
What is the largest prime factor of the
number 600851475143 ?