Class: FizzBuzzer::V4::Fizznum
- Inherits:
-
Object
- Object
- FizzBuzzer::V4::Fizznum
- Defined in:
- lib/fizzbuzzer.rb
Instance Method Summary collapse
- #buzz? ⇒ Boolean
- #fizz? ⇒ Boolean
- #fizzbuzz? ⇒ Boolean
-
#initialize(n) ⇒ Fizznum
constructor
A new instance of Fizznum.
- #val ⇒ Object
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
113 |
# File 'lib/fizzbuzzer.rb', line 113 def buzz?() @n % 5 == 0; end |
#fizz? ⇒ Boolean
112 |
# File 'lib/fizzbuzzer.rb', line 112 def fizz?() @n % 3 == 0; end |
#fizzbuzz? ⇒ Boolean
111 |
# File 'lib/fizzbuzzer.rb', line 111 def fizzbuzz?() @n % 3 == 0 && @n % 5 == 0; end |
#val ⇒ Object
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 |