Home > Programming > Ruby Programming
Ruby Course —animmersive programming course—
Sort Desciption:Licence Copyrightc 2004-2006 Brian Schroeder Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1 ...
Content Inside:Ruby Course —animmersive programming course— Sommercampus 2005-Albert Ludwigs Universität Freiburg Brian Schröder mail@brian-schroeder.de Licence Copyrightc 2004-2006 Brian Schroeder 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; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled"GNU Free Documentation License". Part I Introduction Brian Schröder Ruby Course2004 Simple hello world example This is a must 1 #!/usr/bin/ruby 2 3 puts Hello World 1 Hello World Brian Schröder Ruby Course2004 Function definition Functions are defined using thedefkeyword 1 #!/usr/bin/ruby 2 3 def hello (programmer) 4 puts" Hello #{programmer} " 5 end 6 7 hello( Brian ) 1 Hello Brian Brian Schröder Ruby Course2004 In ruby everything is an object Everything is an object, so get used to the ".method"notation. 1 (5.6).round »6 2 (5.6).class » Float 3 (5.6).round.class » Fixnum 4 5 a string .length »8 6 a string .class » String 7 tim tells .gsub( t , j ) »" jim jells " 8 9 abc .gsub( b , xxx ).length »5 10 11 [ some , things , in , an , array ].length »5 12 [ some , things , in , an , array ].reverse »[" array ", " an ", " in ", " things ", " some "] 13 14 #Youcanevenwrite 15 1.+(2) »3 16 17 #butthereissome sugar for cases like this 18 1+2 »3 Brian Schröder Ruby Course2004 Class definition and inheritance Base Class 1 class Person 2 def initialize (name) 3 @name =name 4 end 5 6 def greet 7 " Hello, my name is #{@name} . " 8 end 9 end 10 11 brian= Person .new( Brian ) 12 puts brian.greet 1 Hello, my name is Brian. Sub Class 13 class Matz < Person 14 ...
Source: ruby.brian-schroeder.de
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Related Files
Ruby Course —animmersive programming course—
Filed under: Programming and Ruby ProgrammingLicence Copyrightc 2004-2006 Brian Schroeder Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1 ...
Programming in Ruby
Filed under: Programming and Ruby ProgrammingProgramming in Ruby Dave Thomas Andy Hun t 1 September 13,2000 1 Dave and Andyare authors of Programming Ruby and The Pragmatic Programmer , both from Addison-Wesley.
A Little Ruby, A Lot of Objects
Filed under: Programming and Ruby Programming... to use Ruby for general-purpose programming - and you should, since its a wonderful rapid- development language for many types of applications - the book to read is Programming Ruby ...
JRuby: Bringing Ruby to the Java Platform
Filed under: Programming and Ruby ProgrammingSun Confidential: Internal Only 2 Agenda - Part One • Who Am I • The Ruby Programming Language • Walkthrough 1: Introduction to Ruby • Why Use Ruby? • JRuby:
Sockets programming in Ruby
Filed under: Programming and Ruby ProgrammingSockets programming in Ruby Explore Rubysfundamental sockets interfaces for networking applications Skill Level: Intermediate M. Tim Jones ( mtj@mtjones.com ) Senior Principal ...
