Skip to content

Instantly share code, notes, and snippets.

@0x0dea
Created July 17, 2015 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0x0dea/628de90e12acc1874a9a to your computer and use it in GitHub Desktop.
Save 0x0dea/628de90e12acc1874a9a to your computer and use it in GitHub Desktop.
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