module FizzBuzzer::V12a
Public Instance Methods
fizzbuzz()
click to toggle source
# File lib/fizzbuzzer.rb, line 350 def fizzbuzz fizzbuzz_engine( 1..100, [["Fizz", -> n { n % 3 == 0 }], ["Buzz", -> n { n % 5 == 0 }]]) end
fizzbuzz_engine(range, factors)
click to toggle source
# File lib/fizzbuzzer.rb, line 340 def fizzbuzz_engine(range, factors) range.map do |n| result = "" factors.each do |(name, predicate)| result << name if predicate.call(n) end result == "" ? n : result end end