Class: FizzBuzzer::V4::Fizznum

Inherits:
Object
  • Object
show all
Defined in:
lib/fizzbuzzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(n) ⇒ Fizznum

Returns a new instance of Fizznum.



107
108
109
# File 'lib/fizzbuzzer.rb', line 107

def initialize(n)
  @n = n
end

Instance Method Details

#buzz?Boolean

Returns:

  • (Boolean)


113
# File 'lib/fizzbuzzer.rb', line 113

def buzz?()     @n % 5 == 0;  end

#fizz?Boolean

Returns:

  • (Boolean)


112
# File 'lib/fizzbuzzer.rb', line 112

def fizz?()     @n % 3 == 0;  end

#fizzbuzz?Boolean

Returns:

  • (Boolean)


111
# File 'lib/fizzbuzzer.rb', line 111

def fizzbuzz?() @n % 3 == 0 && @n % 5 == 0;  end

#valObject



115
116
117
118
119
120
121
# File 'lib/fizzbuzzer.rb', line 115

def val
  if    fizzbuzz? then "FizzBuzz"
  elsif fizz?     then "Fizz"
  elsif buzz?     then "Buzz"
  else  @n
  end
end