Ruby

rubyでfizzbuzz問題

rubyの勉強のために。
一応3と5以外も指定できるようにメソッドで。
ツッコミどころありましたらお願いします。

def fizz_buzz(inp, fi=3, bu=5)
  fizz = (inp % fi).zero?
  buzz = (inp % bu).zero?
  if fizz && buzz
    'FizzBuzz'
  elsif fizz
    'Fizz'
  elsif buzz
    'Buzz'
  else
    inp
  end
end

max_num = 30

(1..max_num).each do |num|
  puts fizz_buzz(num)
end

# 1
# 2
# Fizz
# 4
# Buzz
# Fizz
# 7
# 8
# Fizz
# Buzz
# 11
# Fizz
# 13
# 14
# FizzBuzz
# 16
# 17
# Fizz
# 19
# Buzz
# Fizz
# 22
# 23
# Fizz
# Buzz
# 26
# Fizz
# 28
# 29
# FizzBuzz


一応テストも。

require 'minitest/autorun'

class TestFizzBuzz < Minitest::Test
  def test_fizz_buzz
    assert_equal '1', fizz_buzz(1)
    assert_equal '2', fizz_buzz(2)
    assert_equal 'Fizz', fizz_buzz(3)
    assert_equal '4', fizz_buzz(4)
    assert_equal 'Buzz', fizz_buzz(5)
    assert_equal 'FizzBuzz', fizz_buzz(15)
  end
end