Skip to content

Instantly share code, notes, and snippets.

@maxwellE
Last active December 14, 2015 12:39
Show Gist options
  • Save maxwellE/5087815 to your computer and use it in GitHub Desktop.
Save maxwellE/5087815 to your computer and use it in GitHub Desktop.
FizzBuzz example implementation
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