Created
October 25, 2009 10:24
-
-
Save agrimm/217992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[agrimm@computer_name using_block_test]$ more skippy.rb | |
#This is from the Pickaxe | |
module Kernel | |
old_system_method = instance_method(:system) | |
define_method(:system) do |*args| | |
result = old_system_method.bind(self).call(*args) | |
puts "system(#{args.join(', ')}) returned #{result.inspect}" | |
result | |
end | |
end | |
system("date") | |
system("kangaroo", "-hop 10", "skippy") | |
[agrimm@computer_name using_block_test]$ ruby -W2 skippy.rb | |
Mon Oct 26 08:17:25 EST 2009 | |
system(date) returned true | |
system(kangaroo, -hop 10, skippy) returned false | |
[agrimm@computer_name using_block_test]$ [alias for ruby 1.9.1] -W2 skippy.rb | |
skippy.rb:3: warning: method redefined; discarding old system | |
Mon Oct 26 08:17:31 EST 2009 | |
system(date) returned true | |
system(kangaroo, -hop 10, skippy) returned nil | |
[agrimm@computer_name using_block_test]$ [alias for ruby 1.9.1] -W1 skippy.rb | |
Mon Oct 26 08:18:44 EST 2009 | |
system(date) returned true | |
system(kangaroo, -hop 10, skippy) returned nil | |
[agrimm@computer_name using_block_test]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment