FizzBuzz in Sinatra

The other night I attended the Ruby MKE Meetup. The topic was the 7 Degrees of FizzBuzz by Bill Gathen. Unfortunately, we weren’t able to get to the final “degree” before the end of the meeting. So, for those who are interested, here is my solution:

require 'sinatra'

get '/' do
  erb :index

@@ index

    <% (1..99).each do |x| %>
    <%= ("fizzbuzz" if x % 15 == 0) ||         ("fizz" if x % 3 == 0) ||         ("buzz" if x % 5 == 0) ||         x %>

    <% end %>

Clint Laskowski

Hello! My name is Clint Laskowski, and I'm an Information Security Professional who helps clients identify, assess, treat, and monitor risks to information and information systems.

More Posts - Website