Module: FizzBuzzNumerics
- Included in:
- Numeric
- Defined in:
- lib/fizz-buzz.rb
Instance Method Summary collapse
- #buzz? ⇒ Boolean
-
#fizz? ⇒ Boolean
For testing the Fizz-, Buzz-, or Fizzbuzz-ness of a Fixnum 3.fizz? # => true 3.buzz? # => false 15.fizzbuzz? # => true.
- #fizzbuzz? ⇒ Boolean
Instance Method Details
#buzz? ⇒ Boolean
34 35 36 |
# File 'lib/fizz-buzz.rb', line 34 def buzz? self % 5 == 0 end |
#fizz? ⇒ Boolean
For testing the Fizz-, Buzz-, or Fizzbuzz-ness of a Fixnum
3.fizz? # => true
3.buzz? # => false
15.fizzbuzz? # => true
Note that using these methods, fizzbuzzy numbers like 15 will fizz, buzz, AND fizzbuzz.
30 31 32 |
# File 'lib/fizz-buzz.rb', line 30 def fizz? self % 3 == 0 end |
#fizzbuzz? ⇒ Boolean
38 39 40 |
# File 'lib/fizz-buzz.rb', line 38 def fizzbuzz? self % 15 == 0 end |