There are many ways to do this kata, including defining a refinement on the integer class as I did here. There are also many ways to print the fizzbuzz data including converting an integer to its representative in fizzbuzz or creating an array of numbers up to that integer with their fizzbuzz contents.
To print each element of an array to STDOUT it can be as simple as requiring a
puts in front of the array. Or if the program is intended to be a ruby
script, calling #each and printing each element of that array. I do not
think that creating an array that prints each line should be part of this
refinement, but instead could be a refinement on the array class, or a special
class by itself with a method like:
def print_each(array)
array.each do |element|
p element
end
endTo create an executable script so that this: ruby fizz_buzz.rb 3 prints:
1
2
fizzPlease see the file print_fizzbuzz, because we have tested the refinement, we can be sure that the correct numbers are printed to STDOUT