Created
January 29, 2016 23:25
-
-
Save Supernats/c97f3782a47ec72852c2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Refinements::StringNumericalConversions | |
| refine String do | |
| def to_integer | |
| banana | |
| Integer(self) | |
| rescue ArgumentError | |
| nil | |
| end | |
| private | |
| def banana | |
| puts "I am a banana!" | |
| end | |
| end | |
| refine NilClass do | |
| def to_integer; end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment