From: Robert Klemme Date: 2007-04-06T18:55:04+09:00 Subject: Re: the most useful code i've written in a while On 06.04.2007 02:54, Trans wrote: > > On Apr 5, 5:34 pm, "Ara.T.Howard" wrote: >> harp:~ > cat errno >> #! /usr/bin/env ruby >> 256.times do |errno| >> puts "#{ errno } => #{ SystemCallError.new(errno).inspect }" >> end > > Nice. > > Hmm... How about an inheritance tree too? robert@fussel /cygdrive/c/Temp $ ruby tr.rb > tree.txt robert@fussel /cygdrive/c/Temp $ wc -l tree.txt 897 tree.txt robert@fussel /cygdrive/c/Temp $ cat tr.rb require 'pp' ins = lambda {|h,k| h[k] = Hash.new(&ins)} tree = Hash.new(&ins) ObjectSpace.each_object(Class) {|cl| tree[cl.superclass][cl] = tree[cl]} pp tree robert@fussel /cygdrive/c/Temp $ head -20 tree.txt {Errno::ESPIPE=>{}, Errno::ENOLINK=>{}, Errno::EISCONN=>{}, ThreadError=>{}, Errno::ENOEXEC=>{}, Errno::EL3HLT=>{}, MatchData=>{}, Errno::ELIBEXEC=>{}, Errno::EMFILE=>{}, Errno::ENETUNREACH=>{}, StandardError=> {RangeError=>{FloatDomainError=>{}}, ThreadError=>{}, RegexpError=>{}, NameError=>{NoMethodError=>{}}, IOError=>{EOFError=>{}}, RuntimeError=>{}, SystemStackError=>{}, TypeError=>{}, SecurityError=>{}, robert@fussel /cygdrive/c/Temp $ robert