[Tobias Reif]
>this is just a learning file, and a test model for a real program
>question 1 of 2: how to code it more appropriately/the Ruby way?
>
>class HoX < String
>
>   def initialize s
>     @s = s
>   end

This is a bit weird. You should decide whether you want an object
that _contains_ a string (in an instance variable @s, for example)
or whether you want an object that _is a kind of_ string (a
subclass of a String). Currently you do both.

What you want depends on what you are trying to model. If you want
to create something which basically is a string, but has some extra
convenience methods, you probably want a subclass of String. If you
want to create something which is not really a string, but has a
string (for example a bank account that has a string for account holder)
you would make a class that does not inherit from String and make the
account holder name an instance variable.

In this example, I think what you want is a subclass of String, so
you would write

	class HoX < String

The initialize method is not really needed, since HoX will get the
initialization method of String, but if you wanted to do something more
in the initializer you would write it

	def initialize s
		super
		# do your stuff
	end

>   def give_string

Not needed, since the object _is a_ String, you can just use the object
directly.

>   def delete_digits
>     HoX.new @s.gsub /\d/,''

	self.class.new(self.gsub /\d/,'')

And similar for the other methods...

> question 2: how to make it possible to write:
> intermingled = h.upcase.repeat.chop # perhaps to_s

With this modification you can do this. h.upcase in String does not
return a String, it returns an object of the same type as h (in
this case a HoX). This is what makes it possible to chain calls in
this way.

Your class, HoX should be as polite, that is why delete_digits
should use self.class.new rather than HoX.new, it makes it possible
for someone to create a subclass of HoX and chain the method
calls.

// Niklas