Created
July 24, 2015 16:45
-
-
Save beaugaines/2036b157bf4db952e087 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 ReverseObject | |
| def reverse | |
| case self | |
| when Integer | |
| to_s.reverse.to_i | |
| when Float | |
| to_s.reverse.to_f | |
| end | |
| end | |
| end | |
| class Numeric | |
| include ReverseObject | |
| end | |
| def reverse_it(data) | |
| return data unless %w(String Fixnum Array).include?(data.class.to_s) | |
| data.reverse | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment