Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created May 7, 2020 05:38
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 baweaver/71f1d96cc37270f51c91d87facaad79f to your computer and use it in GitHub Desktop.
Save baweaver/71f1d96cc37270f51c91d87facaad79f to your computer and use it in GitHub Desktop.
module DashingRefinement
refine Integer do
def -(b) "#{self}-#{b}" end
end
refine String do
def -(b) Date.parse("#{self}-#{b}") end
end
end
module Dashingly
using DashingRefinement
def self.wrap(&fn) instance_eval(&fn) end
end
# Hrm, that's not quite right either.
Dashingly.wrap { 2020-12-11 }
=> 1997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment