As a casual Rubyist I am mainly interested, how ideomatic my solution is.
class Integer
def divisible_by?(n)
(self % n).zero?
end
end
def fizzbuzz(upper_bound)
1.upto(upper_bound).map do |number|
next "fizzbuzz" if number.divisible_by? 3 and number.divisible_by? 5
next "fizz" if number.divisible_by? 3
next "buzz" if number.divisible_by? 5
next number
end
end
puts fizzbuzz 100
Remarks: I borrowed the idea for monkeypatching Integer from @tokland here