Ruby An Introduction

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Ruby An Introduction - Presentation Transcript

    1. FossConf'08 Ruby – An Introduction T.Shrinivasan tshrinivasan@gmail.com Indian Linux User Group, Chennai
    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 ●      \"mixin\" functionality by module ●      iterators and closures
    18. Examples!
    19. 5.times { print “Ruby! \" }
    20. 5.times { print “Ruby! \" } 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 \"Hello\" + name + \" .Welcome\"
    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 \"Count =\" + count.to_s end
    41. Count = 1 Count = 2 Count = 3 Count = 4 Count = 5
    42. count = 0 while count < 10 puts \"Count = \" +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 = [ \"zero\", \"one\", \"two\", \"three\", \"four\" ]  
    48. Array numbers = [ \"zero\", \"one\", \"two\", \"three\", \"four\" ]   >> numbers[0] => \"zero\" >> numbers[4] => \"four\"
    49. Array numbers = [ \"zero\", \"one\", \"two\", \"three\", \"four\" ] >> numbers[3].upcase => \"THREE\" >> numbers[3].reverse => \"eerht\"
    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 = [ \"Shrini\", \"Bala\", \"Suresh\", \"Arul\"]
    54. Sort Array names = [ \"Shrini\", \"Bala\", \"Suresh\", \"Arul\"] names.sort
    55. Sort Array names = [ \"Shrini\", \"Bala\", \"Suresh\", \"Arul\"] names.sort =>[\"Arul\", \"Bala\", \"Shrini\", \"Suresh\"]
    56. More on Arrays ● Reverse ● Length ● Delete ● Join ● Find ● More than 100 methods
    57. Hashes
    58. menu = { :idly => 2.50, :dosai => 10.00, :coffee => 5.00, :ice_cream => 5.00 } menu[:idly] 2.50
    59. Methods
    60. Methods def say_hello(name) result = “Hello, #{name}!” return result end puts say_hello(“world”)
    61. Methods def say_hello(name) “Hello, #{name}!” end puts say_hello(“world”)
    62. Class
    63. Classes class MathWhiz def say_square(value) puts value * value end end sam = MathWhiz.new sam.say_square(5)
    64. Inheritance class Dog < Animal @catagory = “mammal” @legs = 4 end
    65. Module
    66. Modules module Trig PI = 3.141592654 def Trig.sin(x) # .. end def Trig.cos(x) # .. end end
    67. Modules require \"trig\" y = Trig.sin(Trig::PI/4) 0.707106780551956
    68. Attributes class PlainOldRubyObject attr_accessor :food, :drinks attr_reader :advice attr_writer :write_only end
    69. Scope class Poet #public by default def poetry end protected def family_legacy end private def hopes_and_dreams end end
    70. THE END of code :-)
    71. How to Learn?
    72. irb ● interactive ruby ● A ruby Shell ● Instance response ● learn as you type
    73. Web sites Web Sites
    74. http://ruby­lang.org www.ruby­lang.org
    75. www.rubyforge.net
    76. http://www.ruby­forum.com/
    77. Training Centers
    78. Ruby User Groups chennairb@googlegroups.com ● Mailing List ● Meetings ● Tutorial Sessions Join Today
    79. We thank                         and                               for Photos Copyright (c)  2008    Permission is granted to copy, distribute and/or modify this document   under the terms of the GNU Free Documentation License, Version 1.2   or any later version published by the Free Software Foundation. http://www.gnu.org/copyleft/fdl.html   

    + tshrinivasantshrinivasan, 2 years ago

    custom

    1000 views, 2 favs, 0 embeds more stats

    My Ruby Presentation on FossConf 2008,

    More info about this document

    CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

    Go to text version

    • Total Views 1000
      • 1000 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 82
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags