-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathirbrc
65 lines (57 loc) · 1.34 KB
/
irbrc
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'rubygems'
require 'utility_belt'
require 'yaml'
# Better method to list methods of an object :)
# http://rbjl.net/31-the-multi-mega-method-list
module Kernel
def method_list(levels = 1)
if self.is_a? Module
klass, method_function = self, :public_methods
else
klass, method_function = self.class, :public_instance_methods
eigen = self.singleton_methods
if !eigen.empty?
puts :Eigenclass # sorry for not being up to date, I just love the word
puts self.singleton_methods.sort.to_yaml
end
end
levels.times{ |level|
if cur = klass.ancestors[level]
puts cur # put class name
puts cur.send(method_function, false).to_yaml # put methods of the class
else
break
end
}
self # or whatever
end
alias mm method_list
end
# Unix-like functions
# List current directory content, or a directory.
# You can give a symbol to be faster :)
def ls(arg = '*')
arg = arg.to_s if arg.is_a? Symbol
if File.directory? arg
Dir.chdir arg do
Dir['*']
end
else
Dir[arg]
end
end
# Change directory to home, or directory given.
# Like ls function, give a symbol to be faster ;)
def cd(arg = nil)
if arg.nil?
Dir.chdir
else
arg = arg.to_s if arg.is_a? Symbol
Dir.chdir arg
end
Dir.pwd
end
# Where am I?
def pwd
Dir.pwd
end