-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.irbrc
44 lines (38 loc) · 1.02 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
require 'irb/completion'
IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_COLORIZE] = false
Dir.glob(File.expand_path('~/.local/irb*.rb', __FILE__)).each do |file|
require file
end
class Object
# list methods which aren't in superclass
def local_methods(obj = self)
(obj.methods - obj.class.superclass.instance_methods).sort
end
# print documentation
# ri 'Array#pop'
# Array.ri
# Array.ri :pop
# arr.ri :pop
def ri(method = nil)
unless method && method =~ /^[A-Z]/ # if class isn't specified
klass = self.kind_of?(Class) ? name : self.class.name
method = [klass, method].compact.join('#')
end
puts `ri '#{method}'`
end
end
def cop
last_value = IRB.CurrentContext.last_value
%x[echo '#{last_value}' | pbcopy]
"copied \`#{last_value}' to your clipboard"
end
def r
reload!
end
def m(klass)
klass.public_instance_methods - Object.public_instance_methods
end