Your SlideShare is downloading. ×
Ruby 1.9.3 Basic Introduction
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ruby 1.9.3 Basic Introduction

162

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
162
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ruby Programmer’s Best Friend D. Prabu Senior Technical Consultant, Spritle Software PVT LTD, Chennai.
  • 2. History 01 0 2 03 Yukihiro “Matz” Matsumoto February 24, 1993 Matz wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why he decided to design his own language. Perl Java Python Ruby PHP 1987 1991 1993 1995
  • 3. Photo
  • 4. Scripting Language A high-level programming language that is interpreted by another program at runtime rather than compiled by the computer's processor as other programming languages (such as C and C++) are. Scripting languages, which can be embedded within HTML, commonly are used to add functionality to a Web page. JavaScript, ASP, JSP, PHP, Perl, Tcl and Python are examples of scripting languages.
  • 5. Code Sample 5.times { print “Ruby! " }
  • 6. Code Sample 5.times { print “Ruby! " } Ruby! Ruby! Ruby! Ruby! Ruby!
  • 7. Conventions Varialbes Class Variable name_of_the_product @@current_client_id Class Name Constants TeamParty PI Symbols :list_Of_items Instance Variables @current_client
  • 8. Variables Below given are examples of valid variable names orange total_price orange_ _orange buyGift doing747 geting_747 iam23yrsold Below are given examples of invalid variable names 34signals Mango total cost
  • 9. Everything is an object 1.class # => Fixnum 'a'.class # => String :a.class # => Symbol class Record end Record.class # => Class Record.new.class # => Record
  • 10. Method, Class and Invocation def do_work(task_ref) task_ref.assigned_work end Class Task def assigned_work puts “Completed successfully.” end end do_work(Task.new) Method Class Invocation
  • 11. String and Variables variable_name = ‘Nice Infrastructure' # => " Nice Infrastructure " “Good, #{variable_name}" # => “Good, Nice Infrastructure" ‘Good, #{variable_name}' # => "Good, #{variable_name}“
  • 12. String Functions
  • 13. Arrays Array.new # => [] Array.new(3) # => [nil, nil, nil] [] # => [] a = [1,2,3] # => [1, 2, 3] a[0] = 'one' # => "one" a # => ["one", 2, 3] a[-1] # => 3 a[1..2] # => [2, 3]
  • 14. Hashes Hash.new # => {} {} # => {} h = {1 => "one", 2 => "two"} h[1] # => "one“ h["1"] # => nil h[:one] = “course" h[:one] # => "course" h.keys # => [1, 2, :one] h.values # => ["one", "two", "course"]
  • 15. Loops for count in 1..10 i = 1 print count, " Hellon“ count = 10 end until i > count do print i, " Hellon" (1..10).each do |count| i+=1 print count, " Hellon" end end i = 1 5.times { puts “hi” } count = 10 while i <= count do print i, " Hellon" i +=1 end
  • 16. Web Site Links http://tryruby.org http://www.tutorialspoint.com/ruby http://www.ruby- doc.org/docs/ProgrammingRuby http://www.ruby-forum.com/forum/ruby http://stackoverflow.com/questions/tag ged/ruby
  • 17. THANKS SPRITLE SOFTWARE

×