background preloader

Ruby Tutorial with Code Samples

Ruby Tutorial with Code Samples

Ruby Basic Tutorial Troubleshooters.Com, Code Corner and Ruby Revival Present Ruby Basic Tutorial Copyright (C) 2005 by Steve Litt Note: All materials in Ruby Revival are provided AS IS. By reading the materials in Ruby Revival you are agreeing to assume all risks involved in the use of the materials, and you are agreeing to absolve the authors, owners, and anyone else involved with Python Patrol of any responsibility for the outcome of any use of these materials, even in the case of errors and/or omissions in the materials. To the 99.9% of you honest readers who take responsibility for your own actions, I'm truly sorry it is necessary to subject all readers to the above disclaimer. CONTENTS This is a Ruby tutorial for one not knowing Ruby. Ruby can be used as a fully object oriented language, in which case you'd create classes and objects to accomplish everything. If that doesn't make any sense to you, don't worry, it's just a way of saying that Ruby can be very easy to learn and use. Let's count to 10...

Ruby in Twenty Minutes Introduction This is a small Ruby tutorial that should take no more than 20 minutes to complete. It makes the assumption that you already have Ruby installed. (If you do not have Ruby on your computer install it before you get started.) Interactive Ruby Ruby comes with a program that will show the results of any Ruby statements you feed it. Open up IRB (which stands for Interactive Ruby). If you’re using macOS open up Terminal and type irb, then hit enter. irb(main):001:0> Ok, so it’s open. Type this: "Hello World" irb(main):001:0> "Hello World" => "Hello World" Ruby Obeyed You! What just happened? irb(main):002:0> puts "Hello World" Hello World => nil puts is the basic command to print something out in Ruby. Your Free Calculator is Here Already, we have enough to use IRB as a basic calculator: irb(main):003:0> 3+2 => 5 Three plus two. irb(main):004:0> 3*2 => 6 Next, let’s try three squared: irb(main):005:0> 3**2 => 9 In Ruby ** is the way you say “to the power of”. Ok, wait, what was that last one?

Learn to Program, by Chris Pine A Place to Start for the Future Programmer I guess this all began back in 2002. I was thinking about teaching programming, and what a great language Ruby would be for learning how to program. I mean, we were all excited about Ruby because it was powerful, elegant, and really just fun, but it seemed to me that it would also be a great way to get into programming in the first place. Unfortunately, there wasn't much Ruby documentation geared for newbies at the time. And it wasn't very good. What saved me was that I made it really easy for people to contact me, and I always tried to help people when they got stuck. A couple of years later, it was getting pretty good. :-) So good, in fact, that I was ready to pronounce it finished, and move on to something else. It took me another year, but now I think it's really good, mostly because of the hundreds of brave souls who have helped me write it. What's here on this site is the original tutorial, more or less unchanged since 2004.

Ruby on Rails Guides Ruby: How to bring back the joy of programming Ruby is a nice scripting language similar to Perl but cleaner and fully object-orientated. Find here a pointer to the main site about Ruby. Ruby Central also has a lots of data about Ruby. You can find here a link to an online copy of the book « Programming Ruby », by Andrew Hunt & Dave Thomas. Current development version is 1.9.2-p180. Current stable version is 1.8.7-p334, 1.8.6 is really on its way out now. Alongside with Ruby, I’ve discovered the joys of a very neat and nicely designed web application framework called Ruby on Rails . Some of my Ruby code here , oldish ciphers implemented in Ruby following the Test-Driven Development principle. A few years ago, a non-profit association ( in French) was established in France to help further spread Ruby usage and love. Some pictures taken at Solutions Linux 2009 here on Flickr!

Learn Ruby, Ruby on Rails tutorial Ruby on Rails is the web development framework of the moment, powering GitHub, Twitter, Hulu and many more successful apps and websites. The arrival of Rails 4 is the perfect time to learn it. SitePoint’s newest ebook, ‘Jump Start Rails’, from Andy Hawthorne, will get you up to speed with Ruby on Rails in just a weekend. Andy has also prepared the ‘Build your first Rails’ app online course to take you from creating a complete Ruby on Rails 4 app with a log in system all the way to deploying it to Heroku, a leading Rails application hosting environment, in a couple of hours. Also, our all time great, 10 part tutorial from Patrick Lenz can be found here: Learn Ruby on Rails: the Ultimate Beginner’s Tutorial. If you are looking for more advanced topics such as this great Introduction to Sass in Rails, head over to RubySource for fresh tutorials and to discover new Ruby gems. Editor-in-chief, SitePoint & Learnable

At the Forge - Getting Started with Ruby About ten years ago, back when I was working in New York, friends of mine showed me something that knocked my socks off—a program that actually ran inside of the Web browser, without any need for pressing submit. It was sleek, fun to use and seemed like a major paradigm shift. We all were excited about what this new “Java” language and its applets would mean for Web development. Although we didn't quite know where or how it would end, we talked about nothing else for some time. In the decade since then, many different technologies have been hyped as “the next best thing” or “the tool you need to make better Web sites”. You can imagine my surprise, then, when I began to see another “best new method” coming over the horizon—but this one was touted by people I respect, who normally don't give in to hype so quickly. I had been meaning to try Ruby as a language for some time, and the growth of Rails has given me an opportunity to do so. Here is a simple “Hello, world” program in Ruby: #! #! #!

Related: