• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby 1.9.3 Basic Introduction
 

Ruby 1.9.3 Basic Introduction

on

  • 204 views

 

Statistics

Views

Total Views
204
Views on SlideShare
204
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby 1.9.3 Basic Introduction Ruby 1.9.3 Basic Introduction Presentation Transcript

    • Ruby Programmer’s Best Friend D. Prabu Senior Technical Consultant, Spritle Software PVT LTD, Chennai.
    • 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
    • Photo
    • 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.
    • Code Sample 5.times { print “Ruby! " }
    • Code Sample 5.times { print “Ruby! " } Ruby! Ruby! Ruby! Ruby! Ruby!
    • Conventions Varialbes Class Variable name_of_the_product @@current_client_id Class Name Constants TeamParty PI Symbols :list_Of_items Instance Variables @current_client
    • 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
    • Everything is an object 1.class # => Fixnum 'a'.class # => String :a.class # => Symbol class Record end Record.class # => Class Record.new.class # => Record
    • 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
    • String and Variables variable_name = ‘Nice Infrastructure' # => " Nice Infrastructure " “Good, #{variable_name}" # => “Good, Nice Infrastructure" ‘Good, #{variable_name}' # => "Good, #{variable_name}“
    • String Functions
    • 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]
    • 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"]
    • 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
    • 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
    • THANKS SPRITLE SOFTWARE