get_class
-
To get the class name of an object in Ruby, we use the
Object#classmethod. Theclassmethod in Ruby returns a constant which references the class object. To get a string representation of this class name, we must useto_son the result.PHP
class Car {} $bmw = new Car; $result = get_class($bmw); var_export($result); // => 'Car'
Ruby
class Car; end bmw = Car.new p bmw.class.to_s # => "Car"
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

