Created
February 15, 2010 12:28
-
-
Save joshnesbitt/304609 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 PercentagePatch | |
| module InstanceMethods | |
| def as_percentage_of(total) | |
| return 0 if total == 0 | |
| self.to_f / total * 100 | |
| end | |
| end | |
| end | |
| Integer.instance_eval do | |
| include PercentagePatch::InstanceMethods | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment