Nathan Olberding wrote:
> I'm trying to start using mixins and I'm having a little syntactual 
> trouble, if that's a word.
> 
> Here's my test code:
> 
> ---------------
> module One
>         @one = "One!"
>         attr_reader :one
> end
> 
> class Two
>         include One
>         def initialize
>                 puts @one
>         end
> end
> 
> this = Two.new
> ----------------
> 
> I have tried several variations on this, but Two.one always seems to 
> come out as "nil". Is it possible to set it to "One!" by default?

Consider this simple alternative:

module One
  def one
    @one or "One!"
  end
end

If that's not good enough, and you don't mind using a library rather
than bending Ruby's modules to your will yourself, try Ara T. Howard's
Traits library; it deals with this completely.

If you do want to delve into the how of it, check out Ruby Quiz 67:
metakoans.rb and the submitted solutions.

http://rubyquiz.com/quiz67.html

Cheers,
Dave