class FizzBuzz attr_reader :n def initialize(n: 0) @n = n end def datainput begin @n = Integer(gets.chomp) rescue end end def fizzbuzz(n) (1..n).each do |i| if i % 3 == 0 and i % 5 == 0 puts "FizzBuzz" elsif i % 3 == 0 puts "Fizz" elsif i % 5 == 0 puts "Buzz" else puts i end end end def dataoutput fizzbuzz(@n) end def run datainput dataoutput end end if $0 == __FILE__ FizzBuzz.new.run end