Created
January 14, 2010 09:13
-
-
Save closer/277003 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 Kernel | |
| def fizzbuzz limit=100 | |
| (0..limit).each {|n| puts n.to_fizzbuzz } | |
| end | |
| end | |
| class Integer | |
| def is_fizz? | |
| self % 3 == 0 | |
| end | |
| def is_buzz? | |
| self % 5 == 0 | |
| end | |
| def is_fizzbuzz? | |
| is_fizz? && is_buzz? | |
| end | |
| def to_fizzbuzz | |
| is_fizzbuzz? ? 'FizzBuzz' : | |
| is_fizz? ? 'Fizz' : | |
| is_buzz? ? 'Buzz' : | |
| to_s | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment