module FizzBuzzer::V5

Constants

BUZZ
FIZZ

Public Instance Methods

divisible_by?(numerator, denominator) click to toggle source
# File lib/fizzbuzzer.rb, line 134
def divisible_by?(numerator, denominator)
  numerator % denominator == 0
end
divisible_by_3?( numerator ) click to toggle source
# File lib/fizzbuzzer.rb, line 138
def divisible_by_3?( numerator )
  divisible_by?( numerator, 3 )
end
divisible_by_5?( numerator ) click to toggle source
# File lib/fizzbuzzer.rb, line 142
def divisible_by_5?( numerator )
  divisible_by?( numerator, 5 )
end
fizzbuzz() click to toggle source
# File lib/fizzbuzzer.rb, line 146
def fizzbuzz
  (1..100).map do |n|
     fizz = divisible_by_3? n
     buzz = divisible_by_5? n
     case
     when fizz && buzz then FIZZ + BUZZ
     when fizz then FIZZ
     when buzz then BUZZ
     else n
     end
  end
end