Ruby Hell Yeah

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

    Favorites, Groups & Events

    Ruby Hell Yeah - Presentation Transcript

      • “ A language that doesn’t affect the way you think about programming is not worth knowing” — Alan Perlis
    1. Ruby? HELL YEAH! htttp://syamantics.com
    2. ./toc
      • What is Ruby?
      • Installing Ruby
      • Writing our first Ruby program
      • Ruby v/s PHP Syntax
      • What’s so special about Ruby??
    3. What is Ruby?
      • A dynamic, object-oriented programming language that is way too different than C-type languages.
      • Inspired by LISP, Perl, SmallTalk
      • Simple, elegant, natural syntax
      • Created by Yukihiro Matsumoto, a.k.a. Matz
    4. Installing Ruby
      • Windows
      • http://rubyforge.org/frs/?group_id=167
      • Ubuntu
      • sudo apt-get install ruby ri irb
      • You can even try out ruby online!
      • http://tryruby.hobix.com/
    5. Our First Ruby Program
      • Open Your Interactive Ruby Shell
      • Open up Command Prompt/Shell/Terminal and type irb , then hit enter.
      • Now enter this,
      • puts "Hello World!"
    6. Our Second Ruby Program
          • # The Greeter class
        • class Greeter
        • def initialize (name = "World" )
        • @name = name
        • end
        • def say_hi
        • puts "Hi #{ @name } !"
        • end
        • def say_bye
        • puts "Bye #{ @name } , see you next week."
        • end
        • end
          • # Initialize our Greeter
        • g = Greeter.new "Trippert Tech Session“
          • # Say hi
          • g .say_hi
          • # Say bye
          • g .say_bye
    7. Ruby v/s PHP
      • Well, there are number of differences!
      • Ruby is fully OOP, PHP is not.
      • Ruby has got no primitive type, PHP has.
      • In Ruby, classes are objects, In PHP, classes are classes.
      • PHP function calls are Ruby messages.
      • Ruby uses sigil denotes for variable scoping.
      • Ruby has closures, anonymous functions, PHP does not*.
      • … . And many many many more.
      There’s a create_function() function in PHP to create anonymous function though 
    8. Ruby Syntax : Branches
      • if-else
      • switch case
        • if xtra_large
        • do_xtra_large
        • elsif large
        • do_large
        • elsif medium
        • do_medium
        • else #small
        • do_small
        • end
        • do_xtra_large if xtra_large
      ending if
    9. Ruby Syntax : Loops
      • for in
      • Iterators
      • for i in 1. .. 10
      • print i , " Hello " ;
      • end
      • projects = [ "Mobracer" , "GodFatherII" , "Tank" , "Madden Quiz" ]
      • projects .each do |project|
      • puts project
      • end
      while i = 5 while i > 0 puts i i -= 1 end
    10. Ruby Syntax : Containers
      • Arrays
      • Hashes
      • my_array = Array.new
      • my_array = []
      • my_array .push "One"
      • my_array .push "Two"
      • my_array = [ "One" , "Two" ,
      • "Three" , "Four" , "Five" ]
      • new_array = my_array[ 1. . 3 ]
      • new_array = my_array[ 1 , 3 ]
      • people = {
      • "linus" =>{ "lname" => "Torvalds" , "fname" => "Linus" , "project" => "Linux" },
      • "matz" =>{ "lname" => "Matsumoto" , "fname" => "Yukihiro" , "project" => "Ruby" },
      • "DHH" =>{ "lname" => "Hanmer Heinsen" , "fname" => "David" , "project" => "RoR" },
      • "nate" =>{ "lname" => "Abel" , "fname" => "Nate" , "project" => "CakePHP" }
      • }
      • people .select do |nick, info|
      • puts nick
      • info .select do |key, value|
      • puts key , value
      • end
      • end
    11. Ruby Syntax : Subroutines, Modules
      • Subroutines
      • Modules
      • def doubleMe ( number )
      • number * 2
      • end
      • puts doubleMe 3
      • module MyMath
      • def doubleMe ( number )
      • number * 2
      • end
      • end
      • include MyMath
      • puts doubleMe 3
      module MyMath TWO = 2 def MyMath .doubleMe( number ) number * TWO end end include MyMath puts MyMath .doubleMe 3 Modules
    12. Ruby Syntax : Classes and Objects
      • Classes & Objects
      • class MyMath
      • def initialize
      • @two = 2
      • end
      • def doubleMe (number)
      • number * @two
      • end
      • end
      • my_math = MyMath.new
      • puts my_math .doubleMe 4
    13. Ruby Syntax : Inheritance
      • Extending A Class
      • Including Modules
      • class MyParentMath
      • def initialize
      • @two = 2
      • end
      • def doubleMe (number)
      • number * @two
      • end
      • end
      • class MyChildMath < MyParentMath
      • def quadropoleMe (number)
      • doubleMe (number) * doubleMe(number)
      • end
      • end
      • my_math = MyChildMath.new
      • puts my_math .quadropoleMe 4
      • module MyMathModule
      • TWO = 2
      • def doubleMe (number)
      • number * TWO
      • end
      • end
      • class MyChildMath
      • include MyMathModule
      • def quadropoleMe (number)
      • doubleMe (number) * doubleMe(number)
      • end
      • end
      • my_math = MyChildMath.new
      • puts my_math .quadropoleMe 4
    14. Ruby Syntax : Conventions
      • ClassNames
      • method_names and variable_names
      • methods_asking_a_question?
      • slightly_dangerous_methods!
      • @instance_variables
      • $global_variables
      • local_variable
      • SOME_CONSTANTS or OtherConstants
    15. What’s so special about Ruby??
      • Introspection Close to Natural Language Method Redefinition Mixins
      • Implicit Singleton methods Meta-programming Dynamic typing
      • No Primitives Yield Powerful Fully Object Oriented
      • Flexible Symbols Minimalism DRY method_missing
      • Hooks Anonymous function Modules Multiple Inheritence Blocks
      • Reflection Closures Open objects Classes are objects
      • Dynamic Operator Overloading Open classes Sigil Denotes
      • Eval Simplicity Optional Parentheses Iterators attr_accessor
      • Syntactic Sugar Optional Punctuation Write Less Do More
      • TBC...

    + anupom98anupom98, 2 years ago

    custom

    578 views, 0 favs, 3 embeds more stats

    Introduction to Ruby basics and Ruby idioms.

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 578
      • 517 on SlideShare
      • 61 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 10
    Most viewed embeds
    • 41 views on http://www.syamantics.com
    • 17 views on http://syamantics.com
    • 3 views on http://174.143.27.153

    more

    All embeds
    • 41 views on http://www.syamantics.com
    • 17 views on http://syamantics.com
    • 3 views on http://174.143.27.153

    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