class FizzBuzz def self.to_proc ->n{ case 0 when n % 15 then :FizzBuzz when n % 3 then :Fizz when n % 5 then :Buzz else n end } end end puts (1..100).map(&FizzBuzz) # => [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, 31, 32, :Fizz, 34, :Buzz, :Fizz, 37, 38, :Fizz, :Buzz, 41, :Fizz