Skip to content

Instantly share code, notes, and snippets.

@closer
Created January 14, 2010 09:13
Show Gist options
  • Select an option

  • Save closer/277003 to your computer and use it in GitHub Desktop.

Select an option

Save closer/277003 to your computer and use it in GitHub Desktop.
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