Simple Tools

Simple and Elegant Tools for the Web Developer.

Can't Remember That Ruby Method? Try the .methods Method

While installing and browsing the awesome_print gem, I noticed in the examples this little beauty:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require "awesome_print" 

> ap (''.methods - Object.methods).grep(/!/)
[
    [ 0] capitalize!()                                            String
    [ 1]      chomp!(*arg1)                                       String
    [ 2]       chop!()                                            String
    [ 3]     delete!(*arg1)                                       String
    [ 4]   downcase!()                                            String
    [ 5]     encode!(*arg1)                                       String
    [ 6]       gsub!(*arg1)                                       String
    [ 7]     indent!(amount, *indent_string, *indent_empty_lines) String
    [ 8]     lstrip!()                                            String
    [ 9]       next!()                                            String
    [10]   read_ber!(*syntax)                                     String (Net::BER::Extensions::String)
    [11]     remove!(pattern)                                     String
    [12]    reverse!()                                            String
    [13]     rstrip!()                                            String
    [14]      slice!(*arg1)                                       String
    [15]    squeeze!(*arg1)                                       String
    [16]     squish!()                                            String
    [17]      strip!()                                            String
    [18]        sub!(*arg1)                                       String
    [19]       succ!()                                            String
    [20]   swapcase!()                                            String
    [21]         tr!(arg1, arg2)                                  String
    [22]       tr_s!(arg1, arg2)                                  String
    [23]     upcase!()                                            String
]