summaryrefslogtreecommitdiff
path: root/etc/token_class_hierarchy.rb
blob: 4dc3f1f1ca039aac3a3e6942dc8d3ff11630e746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class TokenClass
  def self.const_missing name
    const_set name, Class.new(self)
  end
  def self.method_missing name, &block
    clas = const_missing name
    if block
      clas.instance_eval(&block)
    end
  end
end

class Comment < TokenClass
  Multiline
  class Shebang < self
    Foo
  end
end

p Comment::Blubb::Bla <= Comment::Blubb

ObjectSpace.each_object(Class) { |o| p o if o < TokenClass }