Module: FizzBuzzer::V11b
- Defined in:
- lib/fizzbuzzer.rb
Instance Method Summary collapse
- #divisible_by?(numerator, denominator) ⇒ Boolean
- #divisible_by_3?(numerator) ⇒ Boolean
- #divisible_by_5?(numerator) ⇒ Boolean
- #fizzbuzz ⇒ Object
Instance Method Details
#divisible_by?(numerator, denominator) ⇒ Boolean
312 313 314 |
# File 'lib/fizzbuzzer.rb', line 312 def divisible_by?(numerator, denominator) numerator % denominator == 0 end |
#divisible_by_3?(numerator) ⇒ Boolean
316 317 318 |
# File 'lib/fizzbuzzer.rb', line 316 def divisible_by_3?( numerator ) divisible_by?( numerator, 3 ) end |
#divisible_by_5?(numerator) ⇒ Boolean
320 321 322 |
# File 'lib/fizzbuzzer.rb', line 320 def divisible_by_5?( numerator ) divisible_by?( numerator, 5 ) end |
#fizzbuzz ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/fizzbuzzer.rb', line 324 def fizzbuzz result = [] for n in 1..100 do result << case when divisible_by_3?(n) && divisible_by_5?(n) then "FizzBuzz" when divisible_by_3?(n) then "Fizz" when divisible_by_5?(n) then "Buzz" else n end end result end |