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.



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

def initialize(n)
  @n = n
end

Instance Method Details

#buzz?Boolean

Returns:

  • (Boolean)


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

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

#fizz?Boolean

Returns:

  • (Boolean)


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

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

#fizzbuzz?Boolean

Returns:

  • (Boolean)


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

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

#valObject



118
119
120
121
122
123
124
# File 'lib/fizzbuzzer.rb', line 118

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