Module: Kernel

Defined in:
lib/webget_ruby_ramp/kernel.rb

Overview

Kernel extensions

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.pp_s(*objs) ⇒ Object

Pretty print to a string.

Created by Graeme Mathieson.

See rha7dotcom.blogspot.com/2008/07/ruby-and-rails-how-to-get-pp-pretty.html



42
43
44
45
46
47
48
49
# File 'lib/webget_ruby_ramp/kernel.rb', line 42

def pp_s(*objs)  
  str = StringIO.new  
  objs.each {|obj|  
      PP.pp(obj, str)  
    }  
    str.rewind  
    str.read  
end

Instance Method Details

#caller_method_name(caller_index = 0) ⇒ Object

See:

- Make this fast because its often doing logging & reporting. Inline this and use $1 because it’s empirically faster than /1



31
32
33
# File 'lib/webget_ruby_ramp/kernel.rb', line 31

def caller_method_name(caller_index=0)
  caller[caller_index] =~ /`([^']*)'/ and $1
end

#my_method_nameObject

See:

- Make this fast because its often doing logging & reporting. Inline this and use $1 because it’s empirically faster than /1



18
19
20
# File 'lib/webget_ruby_ramp/kernel.rb', line 18

def my_method_name
  caller[0] =~ /`([^']*)'/ and $1
end