This is a different sort of answer than what you may be hoping for, but I'd really recommend that you deepen your knowledge of Python first. Learn to be pythonic, learn its OOP aspects. Learn its dynamic aspects. Become a Python Wizard.
The reason for this advice, since you are fairly new at this, is that there is a danger that you will try to learn too ...
config['indent'] = 2;
config.indent = 2;
Ruby doesn't support this duality natively, but metaprogramming makes it possible.
We create a class AutoObject that internally stores a dictionary to hold all of the object's properties. Its ...
I'd recommend that you look into sinatra or one of the tutorials that are linked from the ruby docs. They also have a specific tutorial in the docs for moving to ruby from another language.
The reason I'd recommend sinatra is because it is an intro to what ruby is mainly used for in the real world: Web Development. A huge part of ruby is ruby on rails.
Personally, I'd introduce Sinatra first.
Which one of these is going to be easier to explain? Sinatra's "Hello World" example...
get '/' do
Or all the boilerplate that Rails generates...
$ rails new commandsapp
The obvious introductory example would be re-implementing Module#attr_reader / Module#attr_writer / Module#attr_accessor, which after all are typically the first example of metaprogramming a Ruby programmer comes in contact with:
attrs.each do |attr|
define_method(attr) do p instance_variable_get(:"@#...
I think I can answer this via analogy with Python and a surface-level knowledge of Ruby and Sinatra, having skimmed the docs for the latter. From what I can tell the following holds true (although I'd gladly be corrected if it's too reductive):
Sinatra : Ruby on Rails :: Flask : Django
If you want a full framework for Ruby, you go with RoR; if for Python, ...
Perhaps I'm wrong, but your question (and your example) seems to imply that your intention is too "teach them Ruby". For beginners that seems backwards to me. My intention would be to teach them to "solve interesting problems".
Once someone already knows "how to program" in some language it seems fine to teach them a (different) language. But focusing on ...
I almost always teach programming by connecting each component of programming with something in real life. For instance, when explaining variables, I ask the students to imagine them as boxes in which you put things, like food items or gifts or something similar.
For methods, I ask them to think of their friends. For instance, there will be a 'rich' friend,...
Subroutines/methods are a way to reuse code. As is iteration (loops). They are also a way to document what code does.
Therefore show how they can be used to reduce the amount of code: to make the program simpler, and to make it more readable. Note that there is often resistance as a new concept: as, temporarily, it does not make sense, so is not simpler.
Have them write up a straight class and document it. Here are some ideas.
Complex Numbers: Create a class that spawns complex numbers and does their arithmetics. Throw exceptions where needed.
Big Fraction: Create a class for extended-precision rational arithmetic. You will need +, -, * and /.
Quaternions: These are used extensively in computer ...
A documentation system similar to Python's, where documentation isn't stored in the source text, but as dynamic data inside of instance variables of the documented objects themselves.
This also allows you to talk about Ruby's object model, e.g. the fact that methods aren't objects and thus you can't store the documentation of a method inside the method, you ...