Getting an object’s methods without the inherited methods

test = SomeObject.new
test.methods - test.class.superclass.new.methods

Or is there a shorter, less convoluted way?

Update November 12th: yes there seems to be…

puts String.instance_methods(false)

From the Ruby For Rails Book, page 254, paragraph 9.8.1….

But: String.instance_methods(false).size = 83 , whereas (test.methods - test.class.superclass.new.methods).size = 102 (with test a string object).

>> puts (test.methods - test.class.superclass.new.methods - String.instance_methods(false)).sort
<
<=
>
>=
all?
any?
between?
collect
detect
each_with_index
entries
find
find_all
grep
inject
map
max
member?
min
partition
reject
select
sort
sort_by
zip
=> nil
>> exit

The difference seems to be the methods of the mixed in modules…

Installing a Gem from a local file

What if you want to install a Gem that you did not find on Rubyforge - one that was mailed to you or that you have downloaded?

Simple: just add the downloaded file name to the gem install command, instead of the name of the gem. For example, installing the “simple-rss” extension would be:

  • with the path included if the file is not in the directory where your command line is:
    gem install D:\downloads\ruby_gems\simple-rss-1.1.gem
  • or without, if you change directory in your command line to where the file is
    gem install simple-rss-1.1.gem

Instead of just:
gem install simple-rss

This might seem evident to most of you, but it took me a while to figure out as rubyforge.org was down today and I had to rely on this mirror.