14
Ruby Basics

Ruby on rails - Ruby Basics

Embed Size (px)

DESCRIPTION

Code of the world we emplemented while the speak https://gist.github.com/blazeeboy/5301160

Citation preview

Page 1: Ruby on rails - Ruby Basics

Ruby Basics

Page 2: Ruby on rails - Ruby Basics

Ruby syntax

Practice

Solve last assignment

New assignment

Questions

Page 3: Ruby on rails - Ruby Basics

Irb

Ruby

SublimeText 2

http://www.ruby-doc.org

Page 4: Ruby on rails - Ruby Basics

Print hello world

Create world variables

Write them in files

Page 5: Ruby on rails - Ruby Basics

def name(param1,param2,param3)

…code here…

end

Create a function that print world data

Page 6: Ruby on rails - Ruby Basics

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

Page 7: Ruby on rails - Ruby Basics

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

Page 8: Ruby on rails - Ruby Basics

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

Page 9: Ruby on rails - Ruby Basics

Block_given?

Yield

Block

Block with parameter

Burry dead humans

Page 10: Ruby on rails - Ruby Basics

Dir

Pwd

Glob

Mkdir

Exists?

Open

Close

Enteries

each

• File

• Open

• Close

• Delete

• Readlines

• Rewind

• write

Page 11: Ruby on rails - Ruby Basics

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/

Page 12: Ruby on rails - Ruby Basics

Solve

http://projecteuler.net/problem=3

Read

http://guides.rubyonrails.org/getting_started.ht

ml

Practice (Plus)

http://railsforzombies.org/

Page 13: Ruby on rails - Ruby Basics

The prime factors of 13195 are 5, 7, 13 and

29.

What is the largest prime factor of the

number 600851475143 ?

Page 14: Ruby on rails - Ruby Basics