[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

the most useful code i've written in a while

Ara.T.Howard

4/5/2007 9:35:00 PM

4 Answers

James Gray

4/5/2007 11:58:00 PM

0

On Apr 5, 2007, at 4:34 PM, Ara.T.Howard wrote:

> 17 => #<Errno::EEXIST: File exists>

I was just wondering today if I could rescue this error in a cross-
platform safe way.

James Edward Gray II

Trans

4/6/2007 12:55:00 AM

0



On Apr 5, 5:34 pm, "Ara.T.Howard" <ara.t.how...@noaa.gov> 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?

T.


Robert Klemme

4/6/2007 9:53:00 AM

0

On 06.04.2007 02:54, Trans wrote:
>
> On Apr 5, 5:34 pm, "Ara.T.Howard" <ara.t.how...@noaa.gov> 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

Sean O'Halpin

4/6/2007 2:13:00 PM

0

On 4/6/07, Robert Klemme <shortcutter@googlemail.com> wrote:
> On 06.04.2007 02:54, Trans wrote:
> >
> > On Apr 5, 5:34 pm, "Ara.T.Howard" <ara.t.how...@noaa.gov> 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

Nice! Small refinement for tree of Exceptions:

tree[cl.superclass][cl] = tree[cl] if cl <= Exception

Regards,
Sean