-
-
Save palkan/7da70e5654c034c1c77622f893fbb8e7 to your computer and use it in GitHub Desktop.
[ruby-next] ifn't
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
# Inspired by the joke from the C# community: | |
# https://twitter.com/phantom_thegame/status/1745215916348952671 | |
RubyNext.define_text_rewriter "ifn't" do | |
def safe_rewrite(source) | |
source.gsub(/(\b)ifnot(\b)/, '\1unless\2') | |
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
require "date" | |
using(Module.new do | |
refine Date do | |
def weekend? = saturday? or sunday? | |
end | |
end) | |
ifnot Date.today.weekend? | |
puts "Keep working ⚙️" | |
else | |
puts "Relax ☺️" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment