-
-
Save 0x0dea/628de90e12acc1874a9a 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
module Uberscore | |
class Context | |
v, $VERBOSE = $VERBOSE, nil | |
undef_method *instance_methods | |
$VERBOSE = v | |
def initialize | |
@chain = [] | |
end | |
def method_missing *args | |
@chain << args and self | |
end | |
def to_proc | |
-> obj { @chain.reduce(obj) { |obj, args| obj.send *args } } | |
end | |
end | |
Kernel.send(:define_method, :_) { Context.new } | |
end | |
%w[0x 0d ea].map(&_.hex.divmod(13)[1] == 0) # => [true, true, true] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment