Last active
December 14, 2015 12:39
-
-
Save maxwellE/5087815 to your computer and use it in GitHub Desktop.
FizzBuzz example implementation
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
class FizzBuzz | |
def initialize(lower_bound,upper_bound) | |
@lower_bound = lower_bound | |
@upper_bound = upper_bound | |
end | |
def evaluate | |
(@lower_bound..@upper_bound).map do |x| | |
if (x % 5) == 0 && (x % 3) == 0 | |
"FizzBuzz" | |
elsif (x % 5) == 0 | |
"Buzz" | |
elsif (x % 3) == 0 | |
"Fizz" | |
else | |
x.to_s | |
end | |
end | |
end | |
end | |
puts FizzBuzz.new(1,100).evaluate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment