Better ruby way for caseing on class?

Sure. Drop the call to to_s() and the ' .. 's around the class
names. Case calls ===() for the condition object and Class defines
===() to do what you expect here.

Er...not quite, because (in his example) he has class objects, not
instances.

[Kernel,String,Object].each do |klass|
case klass
  when Kernel
    puts "I'm doing stuff with object Kernel"
  when String
    puts "I'm doing stuff with object String"
  when Object
    puts "I'm doing stuff with object Object"
  end
end
#=> I'm doing stuff with object Kernel
#=> I'm doing stuff with object Kernel
#=> I'm doing stuff with object Kernel

ebeard, in reality are you trying to handle class objects in your case
statement, or do you have instances of that class that you're trying to
determine the class of?

···

From: James Edward Gray II [mailto:james@grayproductions.net]

Egad, very good point. I apologize.

James Edward Gray II

···

On Oct 4, 2006, at 11:27 AM, Gavin Kistner wrote:

From: James Edward Gray II [mailto:james@grayproductions.net]

Sure. Drop the call to to_s() and the ' .. 's around the class
names. Case calls ===() for the condition object and Class defines
===() to do what you expect here.

Er...not quite, because (in his example) he has class objects, not
instances.

I'm actually dealing with classes. not instances thereof.

Gavin Kistner wrote:

···

From: James Edward Gray II [mailto:james@grayproductions.net]
> Sure. Drop the call to to_s() and the ' .. 's around the class
> names. Case calls ===() for the condition object and Class defines
> ===() to do what you expect here.

Er...not quite, because (in his example) he has class objects, not
instances.

[Kernel,String,Object].each do |klass|
case klass
  when Kernel
    puts "I'm doing stuff with object Kernel"
  when String
    puts "I'm doing stuff with object String"
  when Object
    puts "I'm doing stuff with object Object"
  end
end
#=> I'm doing stuff with object Kernel
#=> I'm doing stuff with object Kernel
#=> I'm doing stuff with object Kernel

ebeard, in reality are you trying to handle class objects in your case
statement, or do you have instances of that class that you're trying to
determine the class of?