Created
October 26, 2014 00:39
-
-
Save rtyler/527c3c526306b5bf23bf to your computer and use it in GitHub Desktop.
This file contains 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
class SlowLogger | |
future :log, message: String, delay: default(10, Fixnum) do | |
sleep delay | |
puts "It took me #{delay}s to say: #{message}" | |
end | |
end |
This file contains 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
[17:36:11] tyler:typedeaf git:(master*) $ pry -I lib -r 'typedeaf' | |
[1] pry(main)> Typedeaf.global_install | |
=> nil | |
[2] pry(main)> class SlowLogger | |
[2] pry(main)* future :log, message: String, delay: default(10, Fixnum) do | |
[2] pry(main)* sleep delay | |
[2] pry(main)* puts "It took me #{delay}s to say: #{message}" | |
[2] pry(main)* end | |
[2] pry(main)* end | |
=> SlowLogger | |
[3] pry(main)> slow = SlowLogger.new | |
=> #<SlowLogger:0x000008043fa078> | |
[4] pry(main)> slow.log("hello world") ; nil # avoid pry printing Concurrent::Future | |
=> nil | |
[5] pry(main)> It took me 10s to say: hello world | |
[5] pry(main)> | |
[6] pry(main)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment