class Object
Constants
- ANSI_BOLD
- ANSI_GRAY
- ANSI_LGRAY
- ANSI_RESET
Public Instance Methods
pm(*options)
click to toggle source
Print object’s methods
# File lib/rubabel/pm.rb, line 9 def pm(*options) methods = self.methods methods -= Object.methods unless options.include? :more filter = options.select {|opt| opt.kind_of? Regexp}.first methods = methods.select {|name| name =~ filter} if filter data = methods.sort.collect do |name| method = self.method(name) if method.arity == 0 args = "()" elsif method.arity > 0 n = method.arity args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")})" elsif method.arity < 0 n = -method.arity args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")}, ...)" end klass = $1 if method.inspect =~ /Method: (.*?)#/ [name, args, klass] end max_name = data.collect {|item| item[0].size}.max max_args = data.collect {|item| item[1].size}.max data.each do |item| print " #{ANSI_BOLD}#{item[0].rjust(max_name)}#{ANSI_RESET}" print "#{ANSI_GRAY}#{item[1].ljust(max_args)}#{ANSI_RESET}" print " #{ANSI_LGRAY}#{item[2]}#{ANSI_RESET}\n" end data.size end
putsev(*args)
click to toggle source
puts to $stderr if $VERBOSE
# File lib/rubabel/core_ext/putsv.rb, line 10 def putsev(*args) if $VERBOSE $stderr.puts(*args) end end
putsv(*args)
click to toggle source
puts if $VERBOSE
# File lib/rubabel/core_ext/putsv.rb, line 3 def putsv(*args) if $VERBOSE puts(*args) end end