On Tuesday 07 November 2006 09:35, pedro mg wrote:
> Hi,
>
> can we consider this is a mix-in newbie example ? We are giving a new
> feature to method > on our Mixin class.
>
> class Mixin
>   def initialize(a)
>     @a = a
>   end
>   def >(arg)
>     puts "Yep!" if @a > arg
>   end
> end
>
> test = Mixin.new(3)
> test > 1   # -> Yep!
> test.> 1   # -> Yep!
> test.>(1)  # -> Yep!
> puts "Yep, too!" if 2 > 1  # -> Yep, too!
> puts "not now!" if teste < 1  # -> *
>
> * undefined method `<' for #<Mixin:0xb7d35858 @a=3> (NoMethodError)
>
> Works as expected. Thanks,

I wouldn't call it Mixin, that could give some conflict with the concept of 
mixins (i.e. modules)
maybe something like that:

class Compare
  attr_accessor :a

  def initialize a
    @a = a
  end

  def > arg
    puts "Yep!" if @a > arg
  end
end

^manveru