1 require 'auto_mixins'
2
3
4 module TS
5 mix_in_when { true}
6 attr_accessor :ts
7 def initialize; self.ts = Time.now; end
8 end
9
10
11 class Fruits
12 class Fruit
13 attr_accessor :name
14 def initialize(name) super(); self.name = name; end
15 def <=>( other) Order.index(name) - Order.index(other.name); end
16 end
17 Apple = Fruit.new("Apple")
18 Orange = Fruit.new("Orange")
19 Plum = Fruit.new("Plum")
20 def each; Order.each {|f| yield f}; end
21 Order = %w( Apple Orange Plum)
22 end
23
24 if $PROGRAM_NAME == __FILE__
25
26 Module.AddAutomaticMixins
27 puts "Comparable Between? Works -- Fruits::Orange.between?(Fruits::Apple, Fruits::Plum) gives:" + Fruits::Orange.between?(Fruits::Apple, Fruits::Plum).to_s
28 puts "Enumerable Zipping Works: " + Fruits.new.zip( %w( Pie Preserves Streusel)).inspect
29 puts "My Mixed-in Timestamp Works: " + Fruits::Fruit.new("Pear").ts.to_s
30
31 end