No commit activity in last 3 years
No release in over 3 years
See relevant methods in your repl by adding .im to any object
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 2.14
~> 5.0
~> 0.11
~> 10.0
 Project Readme

Interesting Methods

This gem lets you add .im to any object in Ruby to see the interesting methods.

.im stands for 'Interesting Methods'.

Without this gem, to find out an object's methods, you might try this:

MyClass.methods
my_instance.methods

The problem? Because each of these statements show you all of the object's methods, including the inherited methods, it can be hard to find what you're after.


To see only the interesting methods on an object, try one of these statements instead:

MyClass.methods - Object.methods
my_instance.methods - Object.methods
MyClass.singleton_methods(false)
my_instance.instance_methods(false)
MyModule.singleton_methods
MyModule.instance_methods

The interesting_methods gem wraps the above techniques into a simple .im method that you can call on any object (class, instance, module) and display the methods you want:

MyClass.im       # [:my_class_method_a, :my_class_method_b]
my_instance.im   # [:my_instance_method_a, :my_instance_method_b]
MyModule.im      # [:my_module_method_a, :my_module_method_b]

Installation

First install the gem:

gem install interesting_methods

Then create irb and pry rc files if they don't already exist:

touch ~/.irbrc
touch ~/.pryrc

Edit each of those rc files and add the following code:

if Gem::Specification.find_all_by_name('interesting_methods').any?
  require 'interesting_methods'
end

You're all set up now!

Usage

Load up either irb or pry from your command line. Add .im to any object to see its interesting methods.

Examples

Caveat

This gem is not meant to be used in production as it monkey patches Ruby's core Object class.

Development

After checking out this repo, run bin/setup to install dependencies. Then, run rake test to run the tests.

You can run guard for a continuous test runner.

You can run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/seanlerner/interesting_methods.

License

The gem is available as open source under the terms of the MIT License.

Credit

Having interesting_methods available in your repl is something Ruby programmers have been doing for a while. I think I first came across it years ago in a stackoverflow post. Google interesting_methodsand you'll find blog posts and dotfiles with similar functionality already implemented. AFAIK this is the first time its been packaged up in a gem.

Sean Lerner
http://smallcity.ca