Module: FizzBuzzer::V5
- Defined in:
- lib/fizzbuzzer.rb
Constant Summary collapse
- FIZZ =
'Fizz'- BUZZ =
'Buzz'
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
134 135 136 |
# File 'lib/fizzbuzzer.rb', line 134 def divisible_by?(numerator, denominator) numerator % denominator == 0 end |
#divisible_by_3?(numerator) ⇒ Boolean
138 139 140 |
# File 'lib/fizzbuzzer.rb', line 138 def divisible_by_3?( numerator ) divisible_by?( numerator, 3 ) end |
#divisible_by_5?(numerator) ⇒ Boolean
142 143 144 |
# File 'lib/fizzbuzzer.rb', line 142 def divisible_by_5?( numerator ) divisible_by?( numerator, 5 ) end |
#fizzbuzz ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 |
# 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 |