Module: FizzBuzzNumerics

Included in:
Numeric
Defined in:
lib/fizz-buzz.rb

Instance Method Summary collapse

Instance Method Details

#buzz?Boolean

Returns:

  • (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.

Returns:

  • (Boolean)


30
31
32
# File 'lib/fizz-buzz.rb', line 30

def fizz?
  self % 3 == 0
end

#fizzbuzz?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/fizz-buzz.rb', line 38

def fizzbuzz?
  self % 15 == 0
end