Ruby Class Methods List How to Get

Getting a List of Methods Available in Classes in Ruby

This article explains how to get a list of methods available in a specific class in Ruby, with examples.

Shou Arisaka
1 min read
Oct 27, 2025

Getting a List of Methods Available in Classes in Ruby

Here’s an example of how to get a list of methods available in a specific Ruby class.

require_relative '../lib/require'
# require 'csv'
# require 'yaml'

def original_methods(target_class="CSV")
  eval %(@target_class_methods=#{target_class}.methods)
  @target_class_ancestors=['Module','Class','Object','Kernel','BasicObject']
  @target_class_ancestors.each {|ancestor|
    eval %(@target_class_methods-=#{ancestor}.methods)
  }
  return @target_class_methods
end

puts original_methods("YAML")

In this example, we’re getting a list of methods defined in the specified class (in this case, “YAML”).

Notes

The list of methods retrieved includes methods defined in that class and its parent classes, but problems may occur if there are duplicate names. Therefore, please be aware that it may not be completely accurate.

Please understand these limitations when using this method in a hurry.

Share this article

Shou Arisaka Oct 27, 2025

🔗 Copy Links