Last active
December 21, 2015 08:59
-
-
Save douglas-mason/6281935 to your computer and use it in GitHub Desktop.
FizzBuzz in Ruby
This file contains 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
class FizzBuzz | |
def fizz_buzz_puts(number) | |
fb_string = '' | |
if number%3 == 0 | |
fb_string += 'Fizz' | |
end | |
if number%5 == 0 | |
fb_string += 'buzz' | |
end | |
fb_string = number if fb_string =='' | |
puts fb_string | |
end | |
end | |
fb = FizzBuzz.new | |
100.times do |i| | |
fb.fizz_buzz_puts i+1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment