Your SlideShare is downloading. ×
Arulalan  Ruby An Intro
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

Arulalan Ruby An Intro

975
views

Published on

Ruby an introduction. It is 100% OOP Language. And it is very beautiful language. …

Ruby an introduction. It is 100% OOP Language. And it is very beautiful language.
I Love Ruby Very Much. I hope "YOU" too

Published in: Education, Technology

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
975
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
40
Comments
0
Likes
1
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 – An Introduction T.Arulalan tarulalan@gmail.com II Year, M.C.A, Saveetha Enginnering College, Chennai – 602 105
  • 2. Ruby is a Programming Language
  • 3. There are so many  Programming Languages. Why  Ruby?
  • 4. Ruby is simple and beautiful
  • 5. Ruby is Easy to Learn
  • 6. Ruby is Free Open Source Software
  • 7. Ruby on Rails – Web Framework
  • 8. RAA ● Ruby Application Archive ● 1648 projects ● http://raa.ruby-lang.org
  • 9. Rubyforge ● 5070 projects and libraries ● http://rubyforge.org/
  • 10. Can do ● Text Handling ● Games ● System Administration ● NLP ● GUI programming ● Web Applications ● ... ● Database Apps ● Scientific Applications
  • 11. History
  • 12. Ruby Yukihiro “Matz” Matsumoto Japan February 24, 1993
  • 13.  Perl  Java  Python  Ruby  PHP 1987       1991         1993  1995
  • 14.         What is Ruby?
  • 15. Ruby is… A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.
  • 16. Quick and Easy ●      Intrepreted Scripting Language ●      Variable declarations are unnecessary ●      Variables are not typed ●      syntax is simple and consistent ●      memory management is automatic
  • 17. Object Oriented Programming ●      Everything is an object ●      classes, methods, inheritance, etc. ●      singleton methods ●      quot;mixinquot; functionality by module ●      iterators and closures
  • 18. Examples!
  • 19. 5.times { print “Ruby! quot; }
  • 20. 5.times { print “Ruby! quot; } Ruby! Ruby! Ruby! Ruby! Ruby!
  • 21. Everything is an object
  • 22. 100.next
  • 23. 100.next 101
  • 24. “I love Ruby”  .reverse.capitalize
  • 25. “I love Ruby”  .reverse.capitalize “Ybur evol i”
  • 26. 3.hours.from_now
  • 27. 3.hours.from_now Thu Jan 19 22:05:00 Eastern  Standard Time 2006
  • 28. Conventions
  • 29. Variables colored_index_cards
  • 30. Class Names Person
  • 31. Symbols :street_name
  • 32. Instance Variables @school_name
  • 33. Constants Kilograms_Per_Pound
  • 34. Input
  • 35. puts “What is Your name?” name = gets name = name.chomp puts quot;Helloquot; + name + quot; .Welcomequot;
  • 36.             Flow
  • 37. if ( score >= 5000 ) puts “You win!” elsif ( score <= 0 ) puts “Game over.” else puts “Current score: #{score}” end
  • 38. puts “PASS” if mark > 35
  • 39.                     Loop
  • 40. count = 0 5.times do count += 1 puts quot;Count =quot; + count.to_s end
  • 41. Count = 1 Count = 2 Count = 3 Count = 4 Count = 5
  • 42. count = 0 while count < 10 puts quot;Count = quot; +count.to_s count += 1 end
  • 43. Blocks
  • 44. 1.upto(5) { |x| puts x } 1 2 3 4 5
  • 45. 5.downto(1) do |time| print “#{time}... ” puts “!” if time <= 3 end 5... 4... 3... ! 2... ! 1... !
  • 46. Array
  • 47. Array numbers = [ quot;zeroquot;, quot;onequot;, quot;twoquot;, quot;threequot;, quot;fourquot; ]  
  • 48. Array numbers = [ quot;zeroquot;, quot;onequot;, quot;twoquot;, quot;threequot;, quot;fourquot; ]   >> numbers[0] => quot;zeroquot; >> numbers[4] => quot;fourquot;
  • 49. Array numbers = [ quot;zeroquot;, quot;onequot;, quot;twoquot;, quot;threequot;, quot;fourquot; ] >> numbers[3].upcase => quot;THREEquot; >> numbers[3].reverse => quot;eerhtquot;
  • 50. Sort Array primes = [ 11, 5, 7, 2, 13, 3 ]
  • 51. Sort Array primes = [ 11, 5, 7, 2, 13, 3 ] primes.sort
  • 52. Sort Array primes = [ 11, 5, 7, 2, 13, 3 ] primes.sort => [2, 3, 5, 7, 11, 13]
  • 53. Sort Array names = [ quot;Shriniquot;, quot;Balaquot;, quot;Sureshquot;, quot;Arulquot;]
  • 54. Sort Array names = [ quot;Shriniquot;, quot;Balaquot;, quot;Sureshquot;, quot;Arulquot;] names.sort
  • 55. Sort Array names = [ quot;Shriniquot;, quot;Balaquot;, quot;Sureshquot;, quot;Arulquot;] names.sort =>[quot;Arulquot;, quot;Balaquot;, quot;Shriniquot;, quot;Sureshquot;]
  • 56. Multi Type Array names = [ quot;Shriniquot;, quot;Balaquot;, quot;Sureshquot;, quot;Arulquot;, 1, 14, 45, 77, 98.3, 3.14 ]
  • 57. More on Arrays ● Reverse ● Length ● Delete ● Join ● Find ● More than 100 methods
  • 58. Hashes
  • 59. menu = { :idly => 2.50, :dosai => 10.00, :coffee => 5.00, :ice_cream => 5.00 } menu[:idly] 2.50
  • 60. Methods
  • 61. Methods def say_hello(name) result = “Hello, #{name}!” return result end puts say_hello(“world”)
  • 62. Methods def say_hello(name) “Hello, #{name}!” end puts say_hello(“world”)
  • 63. Class
  • 64. Classes class MathWhiz def say_square(value) puts value * value end end sam = MathWhiz.new sam.say_square(5)
  • 65. Inheritance class Dog < Animal @catagory = “mammal” @legs = 4 end
  • 66. Module
  • 67. Modules module Trig PI = 3.141592654 def Trig.sin(x) # .. end def Trig.cos(x) # .. end end
  • 68. Modules require quot;trigquot; y = Trig.sin(Trig::PI/4) 0.707106780551956
  • 69. Attributes class PlainOldRubyObject attr_accessor :food, :drinks attr_reader :advice attr_writer :write_only end
  • 70. Scope class Poet #public by default def poetry end protected def family_legacy end private def hopes_and_dreams end end
  • 71. THE END of code :-)
  • 72. How to Learn?
  • 73. irb ● interactive ruby ● A ruby Shellnce response ● learn as you type
  • 74. Web sites Web Sites
  • 75. http://ruby­lang.org www.ruby­lang.org
  • 76. www.rubyforge.net
  • 77. http://www.ruby­forum.com/