Exercises, examples and other material relating to training module R119. This topic is presented on public courses
Learning to program in Ruby,
Ruby Programming
Background
This module covers elements of the Ruby language
that you'll need to be aware of in your ongoing use,
but may be specialist / occasional in their nature.
Related technical and longer articles
Modules, Mixins and Comparators in Ruby
Articles and tips on this subject | updated |
3799 | Ruby Documentation through rdoc There are three vital elements in any code of significnat size that you write.
• There's the code itself
• There are programmer's comments which provide an overview of the internals and remarks on how you've done things, why certain decisions were made, known issues for future maintainers, ... | 2012-07-14 |
3783 | Load path, load and require in Ruby, and a change from 1.8 to 1.9 Ruby loads files through the require command from a list of directories held in the $: special variable, also known as $LOAD_PATH.
Up to and including Ruby 1.8, this path list included . (the current directory) but from Ruby 1.9 it does not.
Here's a sample program:
require "direct"
p ... | 2012-06-30 |
3622 | Loading Ruby classes - where does Ruby look? If you're loading a Ruby class (or other code) from another source file, use the require function, and give the file name without the .rb on the end of it. Ruby will look in each of the directories listed in $: or $LOAD_PATH in turn, and that list usually includes . (the current directory). See that ... | 2012-02-24 |
3428 | How many days to Christmas? It's only 107 days to Christmas ... courses for next year have already been scheduled [here], the days are drawing in quite quickly, and a Ruby program I wrote to show hoe the Time class works told me. Source code [here].
What's lovely about Ruby is that it has the flexibility of Perl, and the togetherness ... | 2011-09-11 |
3155 | Rake - a build system using code written in Ruby If you're programming in C, C++ or Java, you'll be managing a large number of source files, and using a whole series of commands to build these forward into .o (object) or .class (java class) files, then - in the cases of C and C++ - into executable files.
The make system has been around for as long ... | 2011-02-10 |
1889 | Ruby mixins, modules, require and include A Ruby "mixin" is a way of adding extra code from a module into a class - thus giving the programmer the ability to share code between a number of classes in a way that's in addition to inheritance. So - in effect - it gives multiple inheritance.
In some ways, you can compare a mixin to a (Java) interfaces ... | 2008-11-16 |
1890 | MySQL database from Ruby - an example Both MySQL and Ruby are huge subjects - the former being an excellent database engine and the latter a superb programming language. Yet although each individually is a huge subject, linking the two (i.e. accessing data stored in a MySQL database via a Ruby program) is so each that it's almost trivial.
Here's ... | 2008-11-16 |
1720 | Some Ruby lesser used functions Tidying up (as one does after the recent server move!), I came across a list of functions in Ruby which are important at times, but not exactly top of the list ... and I thought I would share them here - with a few words on each - in the hope that I might save someone a lot of hairpulling at some stage ... | 2008-07-26 |
1586 | Variable types in Ruby In Ruby:
* Variable with names starting with a lower case letter are local variables
* Names starting with a capital letter are constants - you can set them once each time you run a program and then they are fixed
* Names starting with a single @ character are object variables - in other words, you'll ... | 2008-03-22 |
1181 | Good Programming practise - where to initialise variables It's a good idea to initialise your variables directly before you use them for the first time if you're going to use them as accumulators.
By accumulator I mean that you're going to write assignments such as:
$n += 4; # Perl
incr notepad; # Tcl
lappend flcodes [lindex ... | 2007-05-11 |
Examples from our training material
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
[here].
Topics covered in this module
Singletons.
Modules.
Mixins.
The comparator interface.
Additional standard functions and operators.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Ruby,
Lua,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.