Skip to content

Instantly share code, notes, and snippets.

@luk-
Created April 26, 2011 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luk-/941872 to your computer and use it in GitHub Desktop.
Save luk-/941872 to your computer and use it in GitHub Desktop.
class FizzBuzz
def initialize (n)
@n = n
end
def to_s
return "fizzbuzz" if fizzbuzz?
return "fizz" if fizz?
return "buzz" if buzz?
@n.to_s
end
def fizzbuzz?
fizz? && buzz?
end
def fizz?
@n % 3 == 0
end
def buzz?
@n % 5 == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment