Published on

introduction to Ruby

Published in: Technology
1 Comment
  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1.  Alaa Afifi kamal Faculty of computers and information cairo university Vice head to social at fci student union Participant at NYU Abu Dhabi Hackathon Intern at imagine cup university (microsoft) Social media member st scci FR member at Fekra
  2. 2. Introduction to Ruby
  3. 3. Ruby Ruby is a powerful, flexible programming language you can use in web/Internet development, to process text, to create games, and as part of the popular Ruby on Rails web framework. Ruby is: High-level, meaning reading and writing Ruby is really easy—it looks a lot like regular English! Interpreted, meaning you dont need a compiler to write and run Ruby. You can write it here at Codecademy or even on your own computer (many are shipped with the Ruby interpreter built in—well get to the interpreter later in this lesson). Object-oriented, meaning it allows users to manipulate data structures called objects in order to build and execute programs. Well learn more about objects later, but for now, all you need to know is everything in Ruby is an object. Easy to use. Ruby was designed by Yukihiro Matsumoto (often just called "Matz") in 1995. Matz set out to design a language that emphasized human needs over those of the computer, which is why Ruby is so easy to pick up.
  4. 4. RubyOutline : Data taypes(numbers,Booleans and string) Operators (Puts,print) Strings Single _line comments Multi_line comments
  5. 5. Data typesNumbers is a data tybe at Ruby to define numbers justMy _num=25Booleans is a data tybe at Ruby to define Booleans justMy_bool=true or false juststring is a data tybe at Ruby to define strings justMy_string=“Ruby”
  6. 6. operators Addition(+) ,subtraction(-),multiplication(*),Division(/),Exponentiation(**) andmodule(%)Exponentiation(**) is used to get the power of the numberEx: 2 x 2 x 2 =2**3=8 .module(%) is used to get the remainder of divisionEx: 20%3= 2How to write it as a code?My_num=4+4Output= 8
  7. 7. (Puts,print) The print command just takes whatever you give it and prints it in the screen. Puts it adds a new (blank) line after the things you want it to print Ex: puts”Hello” print”Ruby”
  8. 8. stringsLength:if you want to get the legth of string do that Ex: “Ruby”.length output= 4 reverse: this method help us to sort a list of values Ex: “Ruby”.reverse output= ybuR
  9. 9.  Downcase and upcase methods convert a string ALL UPPER CASE or lower case to use upcase or downcase EX: puts”ruby”.upcase the output: RUBY Ex: puts”RUBY”.downcase the output: ruby
  10. 10. Single _line comments A comment is a bit of text that Ruby wont try to run as code: its just for humans to read. Writing good comments not only clarifies your code for other people who may read it, but helps remind you of what you were doing when you wrote the code days, months, or even years earlier.we use # to write a commentEx: “ I love Ruby”.length # this line return the length
  11. 11. Multi_line comments You can write a comment that spans multiple lines by starting each line with a # , but theres an easier way. if you start with =begin and end with =end ,everything between those two expressions will be a comment.Ex:=beginI love ruby it’s nice=end
  12. 12. Thank youCopyrights to:Alaa Afifi