Is there a way to find out all the methods of a class by a command?


Hi All,

I am learning the Ruby API, and I cam across the Ruby in 20 minutes tutorial. In the tutorial there is a class called Greeter. Using the command Greeter.instance_methods(false) you can see all the methods within the class Greeter. I tried this with the built in Ruby Sketchup classes but it didn’t work. Is there a way to find out all the methods of a class?






Sketchup.instance_methods(false)returns an empty array, becauseSketchup is aModule,not aClass.

Modules only have instance methods if they are to be used as a “mix-in” library via the globalincludeorextendmethods.

Sketchup::Edge.instance_methods(false).sortreturns the following array:
[:all_connected, :common_face, :curve, :end, :explode_curve, :faces, :find_faces, :length, :line, :other_vertex, :reversed_in?, :smooth=, :smooth?, :soft=, :soft?, :split, :start, :used_by?, :vertices]

FYI, In older SketchUp versions, under Ruby 1.8.x, the members of the array are strings instead of symbols.

It actually takes a lot longer than 20 minutes to learn Ruby. :wink: (wink)


Other helpful global methods (that get inherited by all classes):



You can find all methods in the api manual:


Sorry, no you cannot.

Only the methods for SketchUp API modules and classes are listed in the online API manual.

For standard Ruby modules and classes, you must consult the Ruby documentation.
Ruby Core Classes
Ruby Standard Library