Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Ruby module R105
Classes and Objects
Exercises, examples and other material relating to training module R105. This topic is presented on public courses Learning to program in Ruby, Ruby Programming

Let's introduce you to Ruby's powerful OO model - it's quick, easy, effective and extensible.
Related technical and longer articles
Basic class definition and use in Ruby

Articles and tips on this subjectupdated
4502Reading and parsing a JSON object in Ruby
Here's a series of three new examples, building up from one another, showing the reading of a JSON feed from a remote web site in Ruby, and the analysis and presentation of that data. The first example - [here] - shows the loading of extra modules to handle reading from the web and the JSON format, ...
4009Clear, concise examples - Ruby classes and objects.
Finding clear, concise examples of how to perform a simple programming task can be surprisingly difficult. "I just want a [Rails] model that doesn't actually use a database table" was an example yesterday. Such shouldn't be difficult, but authors tend to write a simple example and then decide "While ...
3421Ruby off the Rails?
Time was ... "if it's Ruby it must be Rails". The Ruby on Rails framework was the initial killer application that brought the Ruby language to the attention of many, and was so prevelant that it masked other excellent uses. So I'm delighted to see significant other uses of Ruby growing in addition ...
2651Calculation within objects - early, last minute, or cached?
When you create an object with the constructor, you may also set property [attribute] values within it ... or you may follow on with a series of method calls to set the initial values. Then when you pull back values / attributes / properties from your object you return those values, or the results ...
2616Defining a static method - Java, Python and Ruby
Most methods in classes that your write will be run on / applied to individual objects within that class - you'll be asking for the colour of a marker pen, or setting the price of a hotel room. You will NOT - typically - have a model in which all marker pens share the same colour. But - just occasionally ...
2609Scope of variables - important to Ruby on Rails
Yesterday's Ruby on Rails training day brought home just how important it is to ensure that your Ruby variables are correctly "scoped" - that you tell Ruby if they're to be local to the method in which they are defined, to be available to all methods that run on the same objects, to all objects of a ...
2603Ruby objects - a primer
If you're new to Ruby, but familiar with Object Oriented Programming, you might like to take a quick look at the example that I wrote during yesterday's course which shows how all the major OO elements are implemented in Ruby. The sample source is [here]. Here are some of the key facts: • Classes ...
2292Object Orientation in Ruby - intermediate examples
It's when you teach object orientation - the fully Monty, including inheritance, static and dynamic methods and variables, and so on - to a complete novice to programming and that person finds it's one of the easiest parts of the course that you realise: a) Just how many bad ole habits us ancient structure ...
1925Introduction to Object Oriented Programming
"Object Oriented Programming" is a whole new philosophy for programmers who have been writing short scripts for years, and it can be quite frightening to learn with all these new buzzwords like "overriding", "encapsulation" and "polymorphism" creeping in. It's a beautiful concept and a lovely approach, ...
983Blessing in Perl / Member variable in Ruby
How do you decide what member variables you have in an object in Ruby? Well - in Perl, you bless a single hash (or, exceptionally, a list or a scaler), but in Ruby you refer to each variable that you wish to be a member of each object using a preceeding @ character. Perl: bless \%abc; Ruby: @abc ...
Examples from our training material
disc   How to define and use a class
dp.rb   Just define a class for use elsewhere
mm.rb   Accessing class variables, and adding methods
myo.rb   Define and use a class
obtest.rb   Static (class) method definition and use
stan.rb   Standard methods!
thapp.rb   Call in a class from another file
tharn.rb   A class with a test harness
thirdrail   File -> Objects -> Analysis
tj2.rb   Displaying via an Inset class
train.rb   Sample class with accessors and comparator methods
triang.rb   Simple class and use
ucl.rb   Use a class defined in another file
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
Objects, classes and methods.
Constructors and attributes.
Instance and class variables.
Local and global variables.
Class and object methods.
Including files - load and require.
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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/R105.html • PAGE BUILT: Mon Feb 8 18:55:24 2016 • BUILD SYSTEM: WomanWithCat